【发布时间】:2013-12-09 10:41:45
【问题描述】:
由于 JSON 对象不可靠,当我从 json 文本文件创建新的 json 对象时,顺序出错。所以我决定重新排序 json 对象。
正确的顺序(Json文件内容)
{
"211": {
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/09\/0\/0\/A\/Content\/",
"timestamp": 1386514507,
"cover": ["15\/Pg015.png",
"16\/Pg016.png",
"1\/Pg001.png",
"2\/Pg002.png"],
"year": "2013",
"month": "12",
"day": "09",
"issue": "2013-12-09",
"id": "211"
},
"210": {
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/08\/0\/0\/A\/Content\/",
"timestamp": 1386415087,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"year": "2013",
"month": "12",
"day": "08",
"issue": "2013-12-08",
"id": "210"
},
"209": {
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/07\/0\/0\/A\/Content\/",
"timestamp": 1386331278,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"year": "2013",
"month": "12",
"day": "07",
"issue": "2013-12-07",
"id": "209"
},
"208": {
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/06\/0\/0\/A\/Content\/",
"timestamp": 1386255815,
"cover": ["15\/Pg015.png",
"16\/Pg016.png",
"1\/Pg001.png",
"2\/Pg002.png"],
"year": "2013",
"month": "12",
"day": "06",
"issue": "2013-12-06",
"id": "208"
}
}
......
不正确的顺序(当我创建 JsonObject 时)
{
"211": {
"id": "211",
"timestamp": 1386514507,
"cover": ["15\/Pg015.png",
"16\/Pg016.png",
"1\/Pg001.png",
"2\/Pg002.png"],
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/09\/0\/0\/A\/Content\/",
"issue": "2013-12-09",
"month": "12",
"year": "2013",
"day": "09"
},
"210": {
"id": "210",
"timestamp": 1386415087,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/12\/08\/0\/0\/A\/Content\/",
"issue": "2013-12-08",
"month": "12",
"year": "2013",
"day": "08"
},
"195": {
"id": "195",
"timestamp": 1385115154,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/11\/23\/0\/0\/A\/Content\/",
"issue": "2013-11-23",
"month": "11",
"year": "2013",
"day": "23"
},
"194": {
"id": "194",
"timestamp": 1385048906,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/11\/22\/0\/0\/A\/Content\/",
"issue": "2013-11-22",
"month": "11",
"year": "2013",
"day": "22"
},
"197": {
"id": "197",
"timestamp": 1385306370,
"cover": ["1\/Pg001.png",
"2\/Pg002.png",
"3\/Pg003.png",
"4\/Pg004.png"],
"host": "https:\/\/s3-ap-southeast-1.amazonaws.com\/production-source\/ChangSha\/2013\/11\/25\/0\/0\/A\/Content\/",
"issue": "2013-11-25",
"month": "11",
"year": "2013",
"day": "25"
}
}
.....
我现在的 jsonObject 顺序不正确。如何以正确的顺序创建一个新的 json 对象?谢谢
【问题讨论】:
标签: android json performance