How to convert jsonString to JSONObject in Java

前端 未结 19 3257
一生所求
一生所求 2020-11-22 00:39

I have String variable called jsonString:

{\"phonetype\":\"N95\",\"cat\":\"WP\"}

Now I want to convert it into JSON Object. I

19条回答
  •  深忆病人
    2020-11-22 01:22

    For setting json single object to list ie

    "locations":{
    
    }
    

    in to List

    use

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    

    jackson.mapper-asl-1.9.7.jar

提交回复
热议问题