java fastjson解析json字符串

jar的下载

maven方式

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.67</version>
</dependency>

jar包

百度云
链接:https://pan.baidu.com/s/1x_C4ii3OFMXbsoqikmZKGw 
提取码:ku6z

示例

解析json数组

        JSONObject jsonObject = JSON.parseObject(res.toString());
        JSONArray jsonArray = jsonObject.getJSONArray("words_result");
        Iterator<Object> iterator = jsonArray.iterator();
        StringBuilder stringBuilder = new StringBuilder();
        while (iterator.hasNext()) {
            JSONObject object = (JSONObject) iterator.next();
            stringBuilder.append(object.get("words"));
        }

 

posted @ 2020-03-26 21:18  陈彦斌  阅读(3888)  评论(0编辑  收藏  举报