I have to store a nested struct into datastore. As I'm running into the
datastore: flattening nested structs leads to a slice of slices: field
problem, I'd like to store the JSON object as is (as string?) to the datastore. Is this doable in Go?
I have to store a nested struct into datastore. As I'm running into the
datastore: flattening nested structs leads to a slice of slices: field
problem, I'd like to store the JSON object as is (as string?) to the datastore. Is this doable in Go?
You should be able to store the json.RawMessage. See the example in the package docs.
RawMessage is a raw encoded JSON object. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding.
It's a slice of byte
, but you can easily convert it to a string if you wish.