jSON get ERROR Unterminated string

fabioferreiracs

Member
Licensed User
Longtime User
I have a json file with approximately 56,000 characters and 19 array object. when i try parser this file encounter an error. code follows below.

with notepad ++ jsonviewer plugin, I can see the whole structure formed parser. The file pageTwitter.json is correct.

the error message is: Unterminated string at character 46859 of ....
the file pageTwitter.txt is in attachments ! i change the extension to upload

B4X:
Dim parser As JSONParser
Dim ListaMatriz As List   
   
 parser.Initialize(File.ReadString(File.DirRootExternal, pageTwitter.json"))
   
 Log("pageTwitter:" & parser)

ListaMatriz.Initialize
ListaMatriz.Clear

[COLOR="Red"]ListaMatriz = parser.NextArray (ERROR !)[/COLOR]
 

Attachments

  • pageTwitter.zip
    6.6 KB · Views: 185

fabioferreiracs

Member
Licensed User
Longtime User
what happens is this: when I run the code without interruptions, the result is the error shown.
but when I enter a "breakpoint" and continue with "F8" on point "parser.Initialize ..." Seldom happens the error.
I believe Basic4Android need a "timer" to end the command "file.readstring." so, i inserted a code for entering commands had a break of 6 seconds (wait (seconds) ):

B4X:
Dim parser As JSONParser
Dim ListaMatriz As List    
    
 parser.Initialize(File.ReadString(File.DirRootExternal, pageTwitter.json"))
  wait(2)  ' aguarda 2 segundo  

 Log("pageTwitter:" & parser)
  wait(2)  ' aguarda 2 segundo  

ListaMatriz.Initialize
ListaMatriz.Clear

  wait(2)  ' aguarda 2 segundo  
ListaMatriz = parser.NextArray

thus also not the error appears !!!

I am using android emulator. Do you think the error may be the time required for reading file.readstring or may be because I use the sdcard?

Thanks
 
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
I haven't really looked but just reading your post the code below is missing a set of speech marks

B4X:
 parser.Initialize(File.ReadString(File.DirRootExternal, pageTwitter.json"))

it should be

B4X:
 parser.Initialize(File.ReadString(File.DirRootExternal, "pageTwitter.json"))

Not sure if it will help

Stu
 
Upvote 0

fabioferreiracs

Member
Licensed User
Longtime User
hehe, my code has

B4X:
 parser.Initialize(File.ReadString(File.DirRootExternal, "pageTwitter.json"))

i typed wrong here in post.The code is correcty




I haven't really looked but just reading your post the code below is missing a set of speech marks

B4X:
 parser.Initialize(File.ReadString(File.DirRootExternal, pageTwitter.json"))

it should be

B4X:
 parser.Initialize(File.ReadString(File.DirRootExternal, "pageTwitter.json"))

Not sure if it will help

Stu
 
Upvote 0
Top