转自:https://blog.csdn.net/xxssyyyyssxx/article/details/77967836
package com.heiheihaxi.jszxdemo2.test;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
import java.io.*;
import java.util.List;
import java.util.Map;
public class Test9 {
public static void main(String[] args) throws IOException {
File file=new File("C:\\Users\\****\\Desktop\\***\\BigJson.json");
JSONReader reader=new JSONReader(new FileReader(file));
reader.startObject();
while (reader.hasNext()){
String key = reader.readString();
if (key.equals("features")){
reader.startArray();
System.out.println("start:"+key);
while (reader.hasNext()){
String string = reader.readString();
JSONObject jSONObject = (JSONObject) JSONObject.parse(string);
System.out.println(jSONObject.get("attributes"));
}
reader.endArray();
}else {
Object o = reader.readObject();//reader需要再读一次数据,不可少
System.out.println(key+"--"+o);
}
}
reader.endObject();
reader.close();
}
}