3 ms·
Why this? { "_key": "a-key", "_type": "markType" } And not this? { "a-key": "markType" } Why this? { "style": "h1", "children": []
by specialist 8y ago
Why this?
{
"_key": "a-key",
"_type": "markType"
}
And not this?
{
"a-key": "markType"
}
Why this?
{
"style": "h1",
"children": []
}
And not this?
"h1": {
"children": []
}
- dreamer_soul 8y agoMaybe parsers would have a better way of parsing that into a sensible datatype for example look at Gson where you map a json to a Java class, that way you can have a node where you can query if it is H1 or not.. That's just off of my head maybe I'm wrong
- bryanrasmussen 8y agobut what if you have to do this: "h1": { "children": [] }, "h1": { "children": [] } which can't be done because JSON?
- atombender 8y agoThe _key is an ID, not a key as in "JSON key". It's metadata. "style" is optional, so it doesn't make sense for "h1" to be a key. More importantly, JSON is harder to work with when a key can be anything. A schema is more uniform and easy to make strict if all keys are reserved. This also makes it easier to map to data structures used in languages that have struct-type types. Think of the JSON objects here as structs, not key/value pairs: type Block { Style string Children []Block Type string } or whatever.