I wrote a value containing quotation marks in the map and saved this map in JSON.
Now when I try to get the json file back to the map, I get the error:
I need to read json when launching the application, and now it crashes.
How can I fix a json file, if it already has a key-value pair in the value of the quote?
B4X:
Sub CreatJSON
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(Map1)
Dim s As String
s=JSONGenerator.ToPrettyString(2).Replace("\","")
File.WriteString(File.DirInternal,"123.json",s)
End Sub
B4X:
JSON.Initialize(File.ReadString(File.DirInternal&,"123.json"))
Map1=JSON.NextObject
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Class not found: b4a.example3.customlistview, trying: red.ap.expert.customlistview
Error occurred on line: 305 (Main)
org.json.JSONException: Unterminated object at character 35 of {
"123": false,
"456": ""test",
"789": "GGGGHHJKKKJJHGGGH",
"007": "7"
}
at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
at org.json.JSONTokener.readObject(JSONTokener.java:394)
at org.json.JSONTokener.nextValue(JSONTokener.java:100)
at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:48)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at red.ap.expert.main._createitem(main.java:1668)
at red.ap.expert.main._first(main.java:1199)
at red.ap.expert.main$ResumableSub_Activity_Create.resume(main.java:1012)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5281)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:932)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:748)
at dalvik.system.NativeStart.main(Native Method)
How can I fix a json file, if it already has a key-value pair in the value of the quote?