0

I am parsing a JSON file with weekdays and times inside those weekdays. Problem is that whenever I parse them, it's a huge mix up. For example this is my json file:

{
"root1": {
"test": {
  "monday": {
    "08:00-12:20": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "tuesday": {
    "08:00-11:50": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "wednesday": {
    "08:00-11:50": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "friday": {
    "08:00-11:50": {
      "value1": "value2",
      "value3": "value4"
    }
  }
},
"test2": {
  "saturday": {
    "08:05-11:00": {
      "value1": "value2",
      "value3": "value4"
    }
  }
},
"test3": {
  "monday": {
    "12:45-15:10": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "tuesday": {
    "08:55-11:50": {
      "value1": "value2",
      "value3": "value4"
    },
    "15:30-17:55": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "wednesday": {
    "16:35-18:00": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "thursday": {
    "08:00-09:40": {
      "value1": "value2",
      "value3": "value4"
    },
    "10:00-12:25": {
      "value1": "value2",
      "value3": "value4"
    }
  },
  "friday": {
    "16:35-18:00": {
      "value1": "value2",
      "value3": "value4"
    }
  }
}
}
}

So you see the weekdays are in the correct order. But if I parsed them they're like this for example:

  • thursday
  • friday
  • monday
  • wednesday
  • tuesday

How can I parse them into the right order?

4

2 回答 2

1

您可以使用JsonReader进行流读取 - 和控制顺序。

于 2013-06-07T08:44:30.340 回答
0

你必须使用 aJSONArray而不是 a JSONObject。事实上JSONArray保存顺序

于 2013-06-07T08:50:40.730 回答