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