var pageData = {
data: {
results:[]
},
onLoad: function () {
var that = this;
wx.request({
url: ‘https://www.eacye.top’,
method: ‘GET’,
success: function (res) {
that.setData({
results: res.data.TreeList
})
console.log(res.data)
}
})
}}
获取到的JSON为:
console.log(res.data)原样输出,但是……
前端代码为:
却输出为空。
正常情况下应该为:
0 1 2
如果手动把获取到的json复制到下面箭头处是可以正常显示的,但从服务器返回json直接解析却无效:
初步判断为WX不支持三级json解析。如有错漏,请大侠请斧正,谢谢!
Json结构简介:
一级Json 树 为根结点:
res.data.TreeList
res.data.mark
二级Json 叶子节点:
res.data.TreeList.content
三级Json 叶子节点:
res.data.TreeList.content.parentID
json 明细如下:
{
“TreeList”: [
{
“content”: [
{
“frame”: “btn_text_4”,
“view_type”: “picture”,
“orderID”: 21,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5934fec77ac8c.png”,
“stype”: “opacity:1;background-color:transparent;border-color:rgb(34, 34, 34);border-style:none;height:98.4375rpx;width:98.4375rpx;margin-left:auto;margin-right:0;margin-top:0;position:absolute;left:67.96875rpx;top:35.15625rpx;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10004/page10004\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “picture”,
“orderID”: 22,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5934fecbc2fd7.png”,
“stype”: “opacity:1;background-color:transparent;border-color:rgb(34, 34, 34);border-style:none;height:98.4375rpx;width:98.4375rpx;margin-left:auto;margin-right:0;margin-top:0;position:absolute;left:239.0625rpx;top:35.15625rpx;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10005/page10005\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “picture”,
“orderID”: 23,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5934fecf8ee40.png”,
“stype”: “opacity:1;background-color:transparent;border-color:rgb(34, 34, 34);border-style:none;height:98.4375rpx;width:98.4375rpx;margin-left:auto;margin-right:0;margin-top:0;position:absolute;left:407.8125rpx;top:35.15625rpx;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10006/page10006\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “picture”,
“orderID”: 24,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5934fed3c75ae.png”,
“stype”: “opacity:1;background-color:transparent;border-color:rgb(34, 34, 34);border-style:none;height:98.4375rpx;width:98.4375rpx;margin-left:auto;margin-right:0;margin-top:0;position:absolute;left:576.5625rpx;top:35.15625rpx;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10007/page10007\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “text”,
“orderID”: 25,
“pic_text”: “预约课程”,
“stype”: “background-color:rgba(0, 0, 0, 0);border-color:rgb(34, 34, 34);border-style:none;border-width:4.6875rpx;color:rgb(102, 102, 102);font-size:28.125rpx;height:44.53125rpx;line-height:44.53125rpx;margin-left:auto;margin-top:0;opacity:1;text-align:left;position:absolute;left:53.90625rpx;top:154.6875rpx;margin-right:0;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10004/page10004\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “text”,
“orderID”: 26,
“pic_text”: “名师简介”,
“stype”: “background-color:rgba(0, 0, 0, 0);border-color:rgb(34, 34, 34);border-style:none;border-width:4.6875rpx;color:rgb(102, 102, 102);font-size:28.125rpx;height:44.53125rpx;line-height:44.53125rpx;margin-left:auto;margin-top:0;opacity:1;text-align:left;position:absolute;left:227.34375rpx;top:154.6875rpx;margin-right:0;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10005/page10005\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “text”,
“orderID”: 27,
“pic_text”: “优惠券”,
“stype”: “background-color:rgba(0, 0, 0, 0);border-color:rgb(34, 34, 34);border-style:none;border-width:4.6875rpx;color:rgb(102, 102, 102);font-size:28.125rpx;height:44.53125rpx;line-height:44.53125rpx;margin-left:auto;margin-top:0;opacity:1;text-align:left;position:absolute;left:410.15625rpx;top:154.6875rpx;margin-right:0;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10006/page10006\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “btn_text_4”,
“view_type”: “text”,
“orderID”: 28,
“pic_text”: “关于我们\”",
“stype”: “background-color:rgba(0, 0, 0, 0);border-color:rgb(34, 34, 34);border-style:none;color:rgb(102, 102, 102);font-size:28.125rpx;height:44.53125rpx;line-height:44.53125rpx;margin-left:auto;margin-top:0;opacity:1;text-align:left;position:absolute;left:562.5rpx;top:154.6875rpx;margin-right:0;”,
“parentID”: “btn_text_4”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10007/page10007\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
}
],
“customfeature”: {},
“frame”: “btn_text_4”,
“view_type”: “0”,
“stype”: “width:750rpx;height:234.375rpx;background-color:rgb(255, 255, 255);margin-bottom:auto;margin-right:auto;margin-top:28.125rpx;opacity:1;margin-left:auto;”
},
{
“content”: [
{
“frame”: “search”,
“view_type”: “picture”,
“orderID”: 11,
“pic_text”: “img.weiye.me/zcimgdir/album/file_593f8831a32de.png”,
“stype”: “opacity:1;background-color:transparent;border-color:rgb(34, 34, 34);border-style:none;height:70.3125rpx;width:750rpx;margin-left:auto;margin-right:0;margin-top:0;position:absolute;”,
“parentID”: “search”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10016/page10016\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
},
{
“frame”: “search”,
“view_type”: “text”,
“orderID”: 12,
“pic_text”: “课程 名师”,
“stype”: “background-color:rgba(0, 0, 0, 0);border-color:rgb(34, 34, 34);border-style:none;border-width:4.6875rpx;color:rgb(204, 204, 204);font-size:32.8125rpx;height:44.53125rpx;line-height:44.53125rpx;margin-left:auto;margin-top:0;opacity:1;text-align:left;position:absolute;left:234.375rpx;top:18.75rpx;margin-right:0;”,
“parentID”: “search”,
“eventParams”: “{\“inner_page_link\”:\”/pages/page10016/page10016\",\“is_redirect\”:0}",
“eventHandler”: “tapInnerLinkHandler”
}
],
“customfeature”: {},
“frame”: “search”,
“view_type”: “0”,
“stype”: “width:750rpx;height:70.3125rpx;margin-bottom:auto;margin-right:auto;margin-top:-93.75rpx;opacity:1;margin-left:auto;”
},
{
“content”: [
{
“frame”: “swiper”,
“view_type”: “picture”,
“orderID”: 1,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5934e2e8aa5d3.png”,
“parentID”: “swiper”
},
{
“frame”: “swiper”,
“view_type”: “picture”,
“orderID”: 2,
“pic_text”: “img.weiye.me/zcimgdir/album/file_5940aad5d0ac0.png”,
“parentID”: “swiper”
}
],
“customfeature”: {
“autoplay”: true,
“interval”: 2
},
“frame”: “swiper”,
“view_type”: “0”,
“stype”: “height:375rpx;margin-left:auto;margin-right:auto;margin-top:0;opacity:1;”
}
],
“mark”: 1
}