【发布时间】:2012-09-22 05:42:06
【问题描述】:
我想在这段代码中插入 json,但它的工作方式不同!我首先想要CustomerID,然后是Name,但是这个json首先给出Name,然后是CustomerID。我已经根据需要插入了 json,但是为什么它会给出不同的结果,请帮助我..
JSONObject json = new JSONObject();
try {
json.put("CustomerID", "069C21F1-EE87-4FB4-A129-478AEAA454FF");
json.put("Name", "Name_" + (int) Math.random() * 1000);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
【问题讨论】:
-
我现在没有使用,但在调试中我看到订单没有得到维护,根据要求我需要他们按顺序排列
-
为什么要关心订单,JsonObject 使用 HashMap 来存储数据,所以如果你想要一个值,你应该为它提供一个键
-
实际上我将此 json 发布到 url 并在服务器上按顺序对其进行解析...