Json unmarshal on nested struct isn't decoding keys/values

https://play.golang.org/p/WCxWfnfAc8

I’m curious why unmarshal is seeing objects in the devices array (the count of nested Devices matches the input) but not capable of decoding any data into the structs (e.g. all values are empty except the root level.)

Is the JSON malformed or am I just messing up the struct definitions somehow? Is there a way to get better insight into how unmarshal actually interprets this JSON?

Thanks for any assistance.

At a quick glance the first problem I see is private fields in the json input (lowercase field names).
You will need struct tags to unmarshal those.
Take a look at this quick example:
https://play.golang.org/p/JdWl2WImI4

1 Like

https://play.golang.org/p/rVW0TH_XcP

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.