修复翻页后长度为1转jsonArray失败问题
This commit is contained in:
+7
-9
@@ -1,6 +1,9 @@
|
||||
package com.fangjia.script.temp.shenjian
|
||||
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.fangjia.script.lixue.util.DBUtils
|
||||
import com.fangjia.script.statistics.poi.AmapPoi
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBObject
|
||||
|
||||
@@ -10,15 +13,10 @@ import com.mongodb.DBObject
|
||||
class Temp {
|
||||
|
||||
static void main(String[] args) {
|
||||
DBObject query = new BasicDBObject()
|
||||
query.put("city", "重庆")
|
||||
query.put("region", "北碚")
|
||||
query.put("cat", "district")
|
||||
query.put("visible", 0)
|
||||
query.put("name", "人民村")
|
||||
DBUtils.seaweed.find(query).limit(1).each { obj ->
|
||||
println(obj)
|
||||
}
|
||||
String jsonStr = "[{\"id\":\"B0FFLCY016\",\"parent\":[],\"childtype\":[],\"name\":\"杭州馨悦坊公寓\",\"type\":\"住宿服务;住宿服务相关;住宿服务相关\",\"typecode\":\"100000\",\"biz_type\":\"hotel\",\"address\":\"18号大街伊萨卡浩泽园\",\"location\":\"120.383947,30.289931\",\"tel\":[],\"pname\":\"浙江省\",\"cityname\":\"杭州市\",\"adname\":\"钱塘区\",\"importance\":[],\"shopid\":[],\"shopinfo\":\"0\",\"poiweight\":[],\"distance\":\"992\",\"biz_ext\":{\"rating\":[],\"cost\":[],\"hotel_ordering\":\"0\",\"lowest_price\":[],\"star\":[],\"open_time\":[],\"opentime2\":[]},\"photos\":[{\"title\":\"Logo\",\"url\":\"http://store.is.autonavi.com/showpic/7e9c5bdeeba929eb4742102b7c9bd47c\",\"provider\":[]},{\"title\":\"客房\",\"url\":\"http://store.is.autonavi.com/showpic/e4e5771e4de5083877931fda2e360f74\",\"provider\":[]},{\"title\":[],\"url\":\"http://store.is.autonavi.com/showpic/5401e1e105bcbacf550896c7575ee315\",\"provider\":[]}]}]"
|
||||
JSONArray jsonArray = JSONObject.parseArray(jsonStr)
|
||||
List<AmapPoi> ret = JSONObject.parseArray(jsonArray.toJSONString(), AmapPoi.class);
|
||||
print(ret.size())
|
||||
}
|
||||
|
||||
// 万友七季城C区 经度纬度不同106.569161 29.498502 原始106.56881 29.50058 距离231.7003米
|
||||
|
||||
+47
-37
@@ -1,38 +1,48 @@
|
||||
{
|
||||
"id": "B0FFF9RJ2O",
|
||||
"parent": [],
|
||||
"childtype": [],
|
||||
"name": "丁兰广场",
|
||||
"type": "购物服务;商场;购物中心",
|
||||
"typecode": "060101",
|
||||
"biz_type": [],
|
||||
"address": "惠兰雅路与明珠街交汇处东北角",
|
||||
"location": "120.231368,30.353127",
|
||||
"tel": "0571-88111223",
|
||||
"pname": "浙江省",
|
||||
"cityname": "杭州市",
|
||||
"adname": "上城区",
|
||||
"importance": [],
|
||||
"shopid": [],
|
||||
"shopinfo": "0",
|
||||
"poiweight": [],
|
||||
"distance": "37",
|
||||
"biz_ext": {
|
||||
"rating": [],
|
||||
"cost": "13953.00"
|
||||
},
|
||||
"photos": [
|
||||
{
|
||||
"title": [],
|
||||
"url": "http://store.is.autonavi.com/showpic/f5dcc118938358031b45dea7e04faf45"
|
||||
[
|
||||
{
|
||||
"id": "B0FFLCY016",
|
||||
"parent": [],
|
||||
"childtype": [],
|
||||
"name": "杭州馨悦坊公寓",
|
||||
"type": "住宿服务;住宿服务相关;住宿服务相关",
|
||||
"typecode": "100000",
|
||||
"biz_type": "hotel",
|
||||
"address": "18号大街伊萨卡浩泽园",
|
||||
"location": "120.383947,30.289931",
|
||||
"tel": [],
|
||||
"pname": "浙江省",
|
||||
"cityname": "杭州市",
|
||||
"adname": "钱塘区",
|
||||
"importance": [],
|
||||
"shopid": [],
|
||||
"shopinfo": "0",
|
||||
"poiweight": [],
|
||||
"distance": "992",
|
||||
"biz_ext": {
|
||||
"rating": [],
|
||||
"cost": [],
|
||||
"hotel_ordering": "0",
|
||||
"lowest_price": [],
|
||||
"star": [],
|
||||
"open_time": [],
|
||||
"opentime2": []
|
||||
},
|
||||
{
|
||||
"title": [],
|
||||
"url": "http://store.is.autonavi.com/showpic/9a0fd6ceec63e030eac3ee14055206b5"
|
||||
},
|
||||
{
|
||||
"title": [],
|
||||
"url": "http://store.is.autonavi.com/showpic/d9d2a87de3f00294665a2caeb3ee226f"
|
||||
}
|
||||
]
|
||||
}
|
||||
"photos": [
|
||||
{
|
||||
"title": "Logo",
|
||||
"url": "http://store.is.autonavi.com/showpic/7e9c5bdeeba929eb4742102b7c9bd47c",
|
||||
"provider": []
|
||||
},
|
||||
{
|
||||
"title": "客房",
|
||||
"url": "http://store.is.autonavi.com/showpic/e4e5771e4de5083877931fda2e360f74",
|
||||
"provider": []
|
||||
},
|
||||
{
|
||||
"title": [],
|
||||
"url": "http://store.is.autonavi.com/showpic/5401e1e105bcbacf550896c7575ee315",
|
||||
"provider": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
+6
-3
@@ -129,9 +129,12 @@ class GaoDeUtils {
|
||||
}
|
||||
if (json && json.info && json.info == "OK") {
|
||||
count = json.getString("count").toInteger()
|
||||
JSONArray jsonArray = json.pois
|
||||
List<AmapPoi> ret = JSONObject.parseArray(jsonArray.toJSONString(), AmapPoi.class);
|
||||
result.addAll(ret)
|
||||
try {
|
||||
List<AmapPoi> ret = JSONObject.parseArray(json.pois.toString(), AmapPoi.class)
|
||||
result.addAll(ret)
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace()
|
||||
}
|
||||
} else if (json && json.infocode && json.infocode == 10003) {
|
||||
throw new RuntimeException("开发者的日访问量超限,被系统自动封停,第二天0:00会自动解封")
|
||||
} else if (json && json.infocode && json.infocode == 10004) {
|
||||
|
||||
Reference in New Issue
Block a user