直接看构造方法,可以设置有序和无序,默认是false无序,可以设置为true为有序
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
public JSONObject() {
this(16, false);
}
public JSONObject(Map<String, Object> map) {
if (map == null) {
throw new IllegalArgumentException("map is null.");
} else {
this.map = map;
}
}
public JSONObject(boolean ordered) {
this(16, ordered);
}
有序
JSONObject jsonObject = new JSONObject(true);