Hi,
My server returns the following string:
Which I'm trying to decode using the following code:
But I receive the error message:
org.json.JSONException: Expected literal value at character 1 of {\"id\":\"1\",\"Numar\":\"1\",\"TextIntrebare\":\"Cate anotimpuri are un an?\",\"Punctaj\":\"10\",\"Blocata\":\"0\",\"Raspunsuri\":[{\"id\":\"1\",\"idIntrebare\":\"1\",\"Raspuns\":\"1\",\"Corect\":\"0\",\"Blocat\":\"0\"},{\"id\":\"2\",\"idIntrebare\":\"1\",\"Raspuns\":\"3\",\"Corect\":\"0\",\"Blocat\":\"0\"},{\"id\":\"3\",\"idIntrebare\":\"1\",\"Raspuns\":\"4\",\"Corect\":\"1\",\"Blocat\":\"0\"}]}
In what form should the string be received from the server?
Thank you!
My server returns the following string:
B4X:
{"id":"1","Numar":"1","TextIntrebare":"Cate anotimpuri are un an?","Punctaj":"10","Blocata":"0","Raspunsuri":[{"id":"1","idIntrebare":"1","Raspuns":"1","Corect":"0","Blocat":"0"},{"id":"2","idIntrebare":"1","Raspuns":"3","Corect":"0","Blocat":"0"},{"id":"3","idIntrebare":"1","Raspuns":"4","Corect":"1","Blocat":"0"}]}
B4X:
Dim intrebare As String = "[{\""id\"":\""1\"",\""Numar\"":\""1\"",\""TextIntrebare\"":\""Cate anotimpuri are un an?\"",\""Punctaj\"":\""10\"",\""Blocata\"":\""0\"",\""Raspunsuri\"":[{\""id\"":\""1\"",\""idIntrebare\"":\""1\"",\""Raspuns\"":\""1\"",\""Corect\"":\""0\"",\""Blocat\"":\""0\""},{\""id\"":\""2\"",\""idIntrebare\"":\""1\"",\""Raspuns\"":\""3\"",\""Corect\"":\""0\"",\""Blocat\"":\""0\""},{\""id\"":\""3\"",\""idIntrebare\"":\""1\"",\""Raspuns\"":\""4\"",\""Corect\"":\""1\"",\""Blocat\"":\""0\""}]}]"
Dim Lista As Map
Dim JSON As JSONParser
JSON.Initialize(intrebare)
Lista = JSON.NextArray
org.json.JSONException: Expected literal value at character 1 of {\"id\":\"1\",\"Numar\":\"1\",\"TextIntrebare\":\"Cate anotimpuri are un an?\",\"Punctaj\":\"10\",\"Blocata\":\"0\",\"Raspunsuri\":[{\"id\":\"1\",\"idIntrebare\":\"1\",\"Raspuns\":\"1\",\"Corect\":\"0\",\"Blocat\":\"0\"},{\"id\":\"2\",\"idIntrebare\":\"1\",\"Raspuns\":\"3\",\"Corect\":\"0\",\"Blocat\":\"0\"},{\"id\":\"3\",\"idIntrebare\":\"1\",\"Raspuns\":\"4\",\"Corect\":\"1\",\"Blocat\":\"0\"}]}
In what form should the string be received from the server?
Thank you!