Two possible reasons. It is probably nr 2, if you use go-res:
- It must be valid JSON. JSON only allows string keys. go-res produces valid JSON though.
- You cannot have an object as value on a model (
{"from": "someone", "to": "someone else"}
). Sorry, but it is the nested thing again.
If it is 2, and you want the value to be structured JSON, you can “solve” it by JSON encoding the value and add it as a string:
{
"1": "{\"from\":\"someone\":,\"to\":\"someone else\"}",
"2": "{\"from\":\"another\":,\"to\":\"yet another\"}"
}
And use JSON.parse(model[1])
to get the value on the client.
POST EDIT:
Hmm, if more people end up needing something like this, maybe I should consider a new “data” value type, which allows arbitrary data. Eg.:
{
"1": { "data": {"from": "someone", "to": "someone else"}}
}