{"_id":{"$id":"58df84b0159d113438f397aa"},"expiry_date":{"sec":1522579504,"usec":407000},"website":"a.com","email":"pravin_naik89@rediffmail.com","mobile":"9011373730","shop_name":"Skynet servixes","user_id":
{"$id":"58c9127dc2ae8268e752cafb"},"last_updated":{"sec":1491043504,"usec":401000},"approval":0,"register_date":{"sec":1491043504,"usec":401000},"home_delivery":"0","shop_time":{"holiday":"Sunday","time_to":"07:00 ","time_from":"10:00 "},"images":{"shop_img1":"79f525d0-a8e8-7763-ee29-b67304b0822f.jpg"},"category":["Electronics"],"address":{"longitude":"74.40432518720627","latitude":"16.615792240860504","city":"Kolhapur","address":"Hupari"},"__v":0}
{"_id":{"$id":"58e4ab46ed803b2178f77254"},"expiry_date":{"sec":1522917062,"usec":162000},"website":"","email":"amol@gmail.com","mobile":"7276477850","shop_name":"Gurukrupa Enter","user_id":{"$id":"58d634cb558fa13ed3eed97b"},"last_updated":{"sec":1491381062,"usec":159000},"approval":0,"register_date":{"sec":1491381062,"usec":159000},"home_delivery":"0","shop_time":{"holiday":"None","time_to":"09:00 ","time_from":"10:00 "},"images":{"shop_img1":"12a790fd-58af-c45d-d885-0aeb68bad1fd.jpg"},"category":["Electronics"],"address":{"longitude":"74.2438004","latitude":"16.6991044","city":"Kolhapur","address":"Kolhapur"},"__v":0}
这是我的php webservices的结果。 如何将所有数据提取到本地android JSON对象.... ???
答案 0 :(得分:0)
尝试:
JSONObject object = new JSONObject;
object.put("key", "value");
进行适当的循环(循环)以将数据放入JSONObject
。
如果您从网上收到JSONObject
,请查看Volley library
答案 1 :(得分:0)
这是如何将JSON响应转换为JSONObject
的方法JSONObject jsonObject = new JSONObject(response);
JSONObject responseObject = jsonObject.getJSONObject(rootObjectName);
在使用上述两行之前:
必须将响应转换为字符串形式。
rootObjectName是JSON响应中最外层JSONObject的名称。
注意 - 您发布的JSON字符串无效。
答案 2 :(得分:0)
首先,Json无效。
你的json应该如下所示。
[
{
"_id": {
"$id": "58df84b0159d113438f397aa"
},
"expiry_date": {
"sec": 1522579504,
"usec": 407000
},
"website": "a.com",
"email": "pravin_naik89@rediffmail.com",
"mobile": "9011373730",
"shop_name": "Skynet servixes",
"user_id": {
"$id": "58c9127dc2ae8268e752cafb"
},
"last_updated": {
"sec": 1491043504,
"usec": 401000
},
"approval": 0,
"register_date": {
"sec": 1491043504,
"usec": 401000
},
"home_delivery": "0",
"shop_time": {
"holiday": "Sunday",
"time_to": "07:00 ",
"time_from": "10:00 "
},
"images": {
"shop_img1": "79f525d0-a8e8-7763-ee29-b67304b0822f.jpg"
},
"category": [
"Electronics"
],
"address": {
"longitude": "74.40432518720627",
"latitude": "16.615792240860504",
"city": "Kolhapur",
"address": "Hupari"
},
"__v": 0
},
{
"_id": {
"$id": "58e4ab46ed803b2178f77254"
},
"expiry_date": {
"sec": 1522917062,
"usec": 162000
},
"website": "",
"email": "amol@gmail.com",
"mobile": "7276477850",
"shop_name": "Gurukrupa Enter",
"user_id": {
"$id": "58d634cb558fa13ed3eed97b"
},
"last_updated": {
"sec": 1491381062,
"usec": 159000
},
"approval": 0,
"register_date": {
"sec": 1491381062,
"usec": 159000
},
"home_delivery": "0",
"shop_time": {
"holiday": "None",
"time_to": "09:00 ",
"time_from": "10:00 "
},
"images": {
"shop_img1": "12a790fd-58af-c45d-d885-0aeb68bad1fd.jpg"
},
"category": [
"Electronics"
],
"address": {
"longitude": "74.2438004",
"latitude": "16.6991044",
"city": "Kolhapur",
"address": "Kolhapur"
},
"__v": 0
}
]
答案 3 :(得分:0)
您可以使用以下答案将mongodb光标转换为json。 https://stackoverflow.com/a/14232565/4504324
从android方面:你可以使用Retrofit将你的web服务与android sdk集成。
要创建POJO,你可以使用http://www.jsonschema2pojo.org/发布你的json,它会为你创建java模型