I'm trying to marshal to JSON a struct Foo
that has a Values map[string]CellValue
property where CellValue
is another struct. For some reason, the resultant JSON does not contain the data held in the CellValue
struct even though all the keys in the Values
map are present.
Here's a simple playground repro of the issue.
I'm new to Go, can anyone spot the problem here?
The fields of CellValue are unexported (start with a lowercase character). Per the documentation (emphasis mine), "Each exported struct field becomes a member of the object" - meaning unexported values are ignored when marshaling or unmarshaling.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.