" working_days":[ { " day_id":2, "来自":11, "到":22 }, { " day_id":3, "来自":10, "到":23 } ],
我需要发布的脚本的一部分 我和Gson一起使用凌空可以帮助任何人
{
"userId": 2,
"token": "bdajkvnbadkvda1ad1fadf4ad5f1da5",
"name": "Center 123",
"address": "12 Ramsis Str.,",
"lat": "30.31194946131",
"long": "30.31194946131",
"location": "Assute",
"phone": "032365653232",
"owner_name": "Ahmed",
"owner_number": "164956465464",
"registry_number": "2161312",
"taxation_card": "2326-66321",
"contract_code": "1211132",
"remark": "Beside phrmacy",
"working_days": [
{
"day_id": 2,
"from": 11,
"to": 22
},
{
"day_id": 3,
"from": 10,
"to": 23
}
],
"images": [
{
"url": "uploads/center/s51fdf5df1d5.png"
},
{
"url": "uploads/center/s5d1f6d645616.png"
}
]
}
答案 0 :(得分:0)
使用www.jsonschema2pojo.org创建Java对象并使用Gson库解析它:http://www.vogella.com/tutorials/JavaLibrary-Gson/article.html
答案 1 :(得分:0)
您可以使用排球轻松解析您的回复。
try {
JSONObject jsonObject = new JSONObject(your_response);
int userId = jsonObject.getInt("userId");
String token = jsonObject.getString("token");
.
.
.
.
JSONArray working_days = jsonObject.getJSONArray("working_days");
for (int i = 0; i < working_days.length(); i++) {
int day_id = jsonObject.getInt("day_id");
int from = jsonObject.getInt("from");
int to = jsonObject.getInt("to");
}
JSONArray images = jsonObject.getJSONArray("images");
for (int i = 0; i < working_days.length(); i++) {
int url = jsonObject.getInt("url");
}
} catch (JSONException e) {
Log.e(TAG, "Your Boss is Calling");
}