I’m trying to deserialized structured text using .NET’s built in JSON serialization.
It supports discriminators and allows us to set the “type” attribute as value for discriminator.
However, the type discriminator must be placed at the start of the JSON object.
For block elements, this is not the case, at least not in the data I get from the GraphQL endpoint.
As far as I know we can’t control it from the query. Altering the JSON before parsing would be bad for performance.
Can it be changed in DatoCMS ?
{
"type": "paragraph",
"children": [
{
"type": "span",
"value": "is "
},
{
"type": "span",
"marks": [
"strong"
],
"value": "nice"
}
]
},
{
"item": "68089749",
"type": "block" 🚩
},
{
"type": "paragraph",
"children": [
{
"type": "span",
"value": "there was a block above this text"
}
]
}