A JSONObject text must begin with '{' error

后端 未结 4 2301
独厮守ぢ
独厮守ぢ 2021-02-19 00:54

I have this JSON coming from one of our REST service:

[
    \"{\\\"category_name\\\":[\\\"Industry Components\\\"],\\\"categoryId\\\":[1]}\",
    \"{\\\"category         


        
4条回答
  •  Happy的楠姐
    2021-02-19 01:41

    If you get JSONObject text must begin with '{' exception. Then first off all check what did u pass to the JSONObject constructor.

    You should pass the right json.txt file.So make sure what are u passing to jsonobject.

    String request = FileUtils.readFileToString(new File("/home/achaure/Downloads/Amol/KountRestTest/Documents/request.txt"));
    
    JSONObject jsonObject = new JSONObject(request);
    

提交回复
热议问题