I currently have a JSON file, which looks like the following (I have stripped out a lot of the repetitive values, but the structure is the same).
[{
"page" : {
"currentPageNumber" : "page1",
"pageTextLocation" : "\\Assets\\Stories\\Story 1\\Chapter1\\",
"decision":[{
"activeDecision" : true,
"nextPage" : "Page2",
},
{
"activeDecision" : true,
"nextPage" : "Page2",
},
{
"activeDecision" : true,
"nextPage" : "Page2",
}
]
},
"page" : {
"currentPageNumber" : "page2",
"pageTextLocation" : "\\Assets\\Stories\\Story 2\\Chapter2\\",
"decision":[{
"activeDecision" : true,
"nextPage" : "Page3",},
{
"activeDecision" : true,
"nextPage" : "Page3",
},
{
"activeDecision" : true,
"nextPage" : "Page3",
},
{
"activeDecision" : true,
"nextPage" : "Page3",
}]
}}]
I can confirm that the full text of the JSON file loads properly into a string value. However, when I pass that value into JsonArray.Parse(loadedTextValue)
, the return value includes only the final array in the JSON file. The output only displays the last object in the array. If there are two "page" objects, it will only parse the second. If there are three "page objects, it will only parse the third.
However, if I change the key value name of "page" to a unique name, the parser detects all code and turns it into a usable array value. The following data loads completely into a JsonArray
value.
[{
"page" : {
"currentPageNumber" : "page1",
"pageTextLocation" : "\\Assets\\Stories\\Story 1\\Chapter1\\",
"decision":[{
"activeDecision" : true,
"nextPage" : "Page2",
},
{
"activeDecision" : true,
"nextPage" : "Page2",
},
{
"activeDecision" : true,
"nextPage" : "Page2",
}
]
},
"page2" : {
"currentPageNumber" : "page2",
"pageTextLocation" : "\\Assets\\Stories\\Story 2\\Chapter2\\",
"decision":[{
"activeDecision" : true,
"nextPage" : "Page3",},
{
"activeDecision" : true,
"nextPage" : "Page3",
},
{
"activeDecision" : true,
"nextPage" : "Page3",
},
{
"activeDecision" : true,
"nextPage" : "Page3",
}]
}}]
Summary: To parse the entire loaded text file, so that code and iterate through the values, extracting it.
I'm completely out of ideas as to the cause of this behavior. Any input will be greatly appreciated! Thanks!