I am trying to parse a long JSON string with children, sub children, sub sub children etc...So I thought of doing it the recursive way.
Now JSON Parser excepts the string in the following format:
I read the downloaded file using File.ReadString and it does return the string in the above format.
Then I do this:
Now what happens is that ArrayItems.Get(i) returns the string, but without all the necessary double quotes. That is the string
becomes
As a result, even before the recursion starts, I get this error:
org.json.JSONException: Unterminated object at character 60 of {data={after=null, children=[{data={edited=false, body=man committing crimes seems so much easier back in the day. , author_flair_css_class=null, body_html=<div class="md"><p>man committing crimes seems so much easier back in the day. </p>
Character 60 is the space between man and committing. Is this an issue of the JSON parser? How can I successfully continue parsing?
Now JSON Parser excepts the string in the following format:
B4X:
[{"kind": "Listing", "data": {"modhash": "", "children": [{"kind": "t3", "data": .....................
I read the downloaded file using File.ReadString and it does return the string in the above format.
Then I do this:
B4X:
JSON.Initialize(File.ReadString(File.DirInternalCache, "main.json"))
Dim m As Map 'helper map for navigating
Dim MenuItems, ArrayItems As List, domain,url,surl As String, i As Int
ArrayItems = JSON.NextArray
For i=1 To ArrayItems.Size-1
parseJSON (ArrayItems.Get(i))
Next
Now what happens is that ArrayItems.Get(i) returns the string, but without all the necessary double quotes. That is the string
B4X:
{"data"={"after"=null, "children"=[{"data"={"edited"="false", "body"="man committing crimes seems so much easier back in the day." ,
becomes
B4X:
{data={after=null, children=[{data={edited=false, body=man committing crimes seems so much easier back in the day. ,
As a result, even before the recursion starts, I get this error:
org.json.JSONException: Unterminated object at character 60 of {data={after=null, children=[{data={edited=false, body=man committing crimes seems so much easier back in the day. , author_flair_css_class=null, body_html=<div class="md"><p>man committing crimes seems so much easier back in the day. </p>
Character 60 is the space between man and committing. Is this an issue of the JSON parser? How can I successfully continue parsing?