Dear all,
I have a 3rd party JSON data of the shape in the P.S. When I use scalajs.js.JSON.parse
against it, I get unexpetdly variable behaviour. For example, taking text
to be what’s in the P.S. and with
val json = scalajs.js.JSON.parse(text)
val item1 = json.pop()
val id1 = item1._id.toString
id1
evaluates to the string 1
. But,
val node1 = item1.node.sourceType
throws Uncaught TypeError: Cannot read property 'sourceType' of undefined
. I was extecing the string script
here. Furthermore,
val successors1 = item1._successors.pop().toString
evalutaes successors1
to the string undefined
for me. I was rather expeting to get the string 1
here. Does anyone know what I am missing?
TIA,
–Hossein
P.S.
[
{
"node": {
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "Literal",
"value": 123,
"raw": "123",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"tag": 2
},
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"tag": 1
}
],
"sourceType": "script",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"tag": 0,
"funScopeDecls": {}
},
"benv": {
"_map": {
"_buckets": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
},
"_global": true
},
"store": null,
"lkont": [],
"kont": null,
"_successors": [
1
],
"_sstorei": 0,
"_id": 0
},
{
"value": {
"type": 8,
"as": {
"_arr": []
}
},
"store": null,
"lkont": [],
"kont": null,
"_successors": [],
"_sstorei": 0,
"_id": 1
}
]