No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

having JSON from web service, Json Array as a response

   [3]    0:  {    id: 2   name: "a561137"     password: "test"   firstName: "abhishek"    lastName: "ringsia"     organization: "bbb"       }-     1:  {       id: 3   name: "a561023" password: "hello"      firstName: "hello"    lastName: "hello"      organization: "hello"    }-  2:  {   id: 4   name: "a541234"   password: "hello"  firstName: "hello"   lastName: "hello"   organization: "hello"     } 

After Getting Response in JsonArray Getting error while reading Json Object of Json Array :

      List list = new ArrayList();       JSONArray jsonArr = new JSONArray(response);           for (int i = 0; i 

No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) )

回答1:

have To Accept it first as a Json Array ,then while reading its Object have to use Object Mapper.readValue ,because Json Object Still in String .

List list = new ArrayList(); JSONArray jsonArr = new JSONArray(response);  for (int i = 0; i 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!