“A JSONArray text must start with '[' at character 1 of null”

前端 未结 2 1262
说谎
说谎 2021-01-27 05:33

Just wondering what that error could mean? I get it from the following code..

 try{
    JSONArray jArray = new JSONArray(result);
    for(int i=0;i

        
相关标签:
2条回答
  • 2021-01-27 06:16

    Result is null, apparently. Or it simply does not start with [. Print it out before calling JSONArray to see.

    Also take a look at the JSONArray source. It is expecting JavaScript array syntax, e.g.:

    ['this', 'is', 'array', 'syntax']

    0 讨论(0)
  • 2021-01-27 06:26

    text.trim(); text.trim();

    Text is the json file or string , do this at least two times one after another will resolve the problem 99.9%.

    0 讨论(0)
提交回复
热议问题