how to parse unquoted JSON string

后端 未结 3 1367
孤独总比滥情好
孤独总比滥情好 2021-01-17 09:57

I have a JSON string where neither the keys nor the values are quoted and I would like to transform it to a correctly formatted JSON.

{basic:{0:{index:0, lice         


        
3条回答
  •  情歌与酒
    2021-01-17 10:56

    You can use JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES with Jackson to allow unquoted field names:

    JsonFactory factory = new JsonFactory();
    factory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    JsonParser jp = factory.createJsonParser(new FileInputStream("content.json"));
    

提交回复
热议问题