package com.example.demo.lz.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* @author: create by lz
* @copyright: credlink
* @date:2020/4/30 11:11
*/
public class Main {
public static void main(String[] args) {
String GET_URL_ALL = "[{\"id\":0,\"enterprie_id\":13125,\"enterprie_name\":\"恒丰银行股份有限公司\",\"monitor_title\":\"净利微增!这家股份行终于发了年报,压降千亿不良\",\"monitor_item\":\"舆情信息\",\"monitor_level_id\":1,\"alter_date\":\"2020-05-05\",\"publish_date\":null,\"info_url\":\"http://wap.stcn.com/zqsbapp/yw/202005/t20200503_1738670.html\"},{\"id\":0,\"enterprie_id\":13126,\"enterprie_name\":\"恒丰银行股份有限公司\",\"monitor_title\":\"净利微增!这家股份行终于发了年报,压降千亿不良,股东注册地管理层全翻篇\",\"monitor_item\":\"舆情信息\",\"monitor_level_id\":1,\"alter_date\":\"2020-05-05\",\"publish_date\":null,\"info_url\":\"https://new.qq.com/omn/20200503/20200503A0GDQM00.html\"},{\"id\":0,\"enterprie_id\":13121,\"enterprie_name\":\"招商局蛇口工业区控股股份有限公司\",\"monitor_title\":\"招商蛇口深圳项目恐因“捂盘惜售”被查 192套房源遭“分局锁定”\",\"monitor_item\":\"舆情信息\",\"monitor_level_id\":1,\"alter_date\":\"2020-05-05\",\"publish_date\":null,\"info_url\":\"http://dy.163.com/v2/article/detail/FBK4NIEK0512D03F.html\"}]";
//String URL_ALL = "http://syqb.credlink.com/dateSelect";
try {
JSONArray objects = JSONArray.parseArray(GET_URL_ALL);
int size = objects.size();
for (int i = 0; i < size; i++) {
JSONObject jsonObject = objects.getJSONObject(i);
System.out.println(jsonObject.get("monitor_title"));
}
System.out.println("=============");
JSONArray object2 = JSON.parseArray(GET_URL_ALL);
int size2 = object2.size();
for (int i = 0; i < size2; i++) {
JSONObject jsonObject = object2.getJSONObject(i);
System.out.println(jsonObject.get("monitor_title"));
}
System.out.println("1111111111111111111111111111");
if (object2.size() > 0) {
String title = object2.getJSONObject(0).getString("monitor_title");
System.out.println(title);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("=======");
}
}
}
fastjson对JSONArray解析及用法
最新推荐文章于 2025-01-13 13:51:04 发布
877

被折叠的 条评论
为什么被折叠?



