Closed hmassareli closed 10 months ago
It can be done using https://github.com/MaxGraey/as-variant
How? JSON.parse<Variant>(s)
doesn't work, and even if it did, how would I then access parts of the graph from there? Even putting Variant
within another class doesn't seem to work, because it's not tagged with @json
.
An example would be useful. Thanks.
This use case seems more like the example in the other JSON library for AssemblyScript: https://github.com/near/assemblyscript-json#parsing-json
But I really don't want to have two separate JSON libraries in a single project. 😅
I dont know if its possible, but I am trying to parse a JSON file that is unknown at the time I am trying to parse it, for example:
first JSON (possible entry) { "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] } } } } } }
second JSON with an array of objects (possible entry also)
[ { "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] } } } } } } ]