fastJson 将json转换成LinkedHashmap,全部有序

将json转换成LinkedHashmap,全部有序


String jsonStr = "{\"kind\":\"Deployment\",\"metadata.name\":\"nginx-deployment\",\"spec.replicas\":\"3\",\"spec.template.spec.containers\":[{\"name\":\"nginx\",\"image\":\"nginx:1.7.9\",\"ports\":[{\"containerPort\":\"80\"}]},{\"name\":\"nginx\",\"image\":\"nginx:1.7.9\",\"ports\":[{\"containerPort\":\"80\"}]}]}\n";
Map dummyMap =  JSON.parseObject(jsonStr,LinkedHashMap.class, Feature.OrderedField);//关键的地方,转化为有序map

你可能感兴趣的:(java-工具类)