JSON字符串转对象,按顺序输出


 

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;

String jsonStr="{\"id\":\"1\",\"text\":\"哈哈\",\"children\":[{\"id\":\"1\",\"text\":\"01\"},{ \"id\":\"2\",\"text\":\"02\" },{\"id\":\"3\",\"text\":\"03\" }]}";
Map jsonMap=JSON.parseObject(jsonStr, new TypeReference>(){},Feature.OrderedField);
System.out.println(jsonMap.toString());

 

你可能感兴趣的:(JSON字符串转对象,按顺序输出)