the even stupider thing is that in Javascript, even, there is nothing stopping you doing this:

{

"entrytype1":[],

"entrytype1":[]

}

as far as i know, there is no key/vaule uniqueness invariant in JSON objects

it's really annoying for me because everything just gets turned into map[string]interface{} which means a gazillion if/then statements to figure out how to store that properly as typed data

so the alternative is to decode it, and then re-encode it in a structured format

Reply to this note

Please Login to reply.

Discussion

objects are maps. So technically that's illegal in javascript when defining an object, but it is valid syntax. A broken implementation could send that over the wire.

ah, it's javascript, nobody cares lol, everything is text

yes, they have to be encoded as these two types in Go, if you can't pre-define what you are going to get:

map[string]interface{}

[]interface{}

in this case we have this:

map[string][]map[string]interface{}

it is an object, with an array of objects inside it

even better, what is inside it, is all the same object, except one field which is different depending on the text in one of the fields in the object

literally have to either write a generator or spend 2 hours manually writing a thing to unpack it because i have to refer to this shit later, and that wonderous type i just showed you is a serious pain in the ass to iterate, the maps are nondeterministically processed, so you don't know except by selecting on the specially named data field, after you pick the kind field to find out what type to pull out of the data field

anyway, just doing it the manual way because this is the most complex structure in this project i'm doing

it just would have been a lot simpler to make them have names describing what the thing is, so a map with the full set in it, and then inside it an array of the type that fits with that

it would be a more compact representation as well as easier to iterate it