其中使用JSONObject:
这里是:
import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;
代码如下:
package com.xx.util;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import java.util.List;/** * @author fzdds-ryan */public class StringUtil { /** * 测试的man方法 * @param args */ public static void main(String[] args) { // 原始字符串数据 String str = "[{"metric":"base.app.dns.1m","tags":{"carrier":"liantong","access":"wifi","host":"order.api.xx.com","region":"china","version":"2.8","platform":"ssss","url":"/s/s/x/x/c"},"aggregateTags":[],"dps":{"1519698960":1000.0}}]"; // 字符串转换为JSON数组 List<JSONObject> str1 = JSONArray.parseArray(str).toJavaList(JSONObject.class); System.out.println(str1); }}
结果: