Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I would recommend against unmarshalling into an interface, there are simpler solutions to the same problem. Here's a couple suggestions that might get you moving towards an appropriate solution. So one option is to provide custom implementation of UnmarshalJSON (gist.github.com/mdwhatcott/8dd2eef0042f7f1c0cd8) where you would provide custom logic to convert the strings to doubles. The other would be to keep everything the same but define just those inner arrays as an []interface{}. You could also convert after this, just I would recommend being as specific as possible there. Commented Aug 9, 2016 at 22:28
  • For me, better for you to make standard JSON instead. Is the one who generate JSON is external program or your program? Commented Aug 10, 2016 at 4:17
  • I agree, if you have control over the structure of the json, that would be better still. But, as is usually the case you don't, and so you can use my answer. Commented Aug 10, 2016 at 4:40
  • @Apin Unfortunately these are external services generating the JSON. Commented Aug 10, 2016 at 7:08