【发布时间】:2020-04-07 06:34:35
【问题描述】:
有时“box”数组包含有时为空的字典(“box”:[])。 我尝试了很多次,但每次都失败并显示此错误。
错误::无法读取数据,因为它的格式不正确。
{
"id": 57,
"title": "PRIVATE SET :: Royal Blue Colour",
"description": "3 of your selected Fragrances from our Classic Line in an overwhelmingly unique Royal Blue wooden box.",
"volume": "",
"price": 0,
"sub-category": "Assemblage",
"image": "http://192.168.1.163/ramasaat/public/storage/images/Products/e0dc5e9d15704ccac5c0965e9e2c782e.jpg",
"related": [
{
"id": 55,
"title": "ELITE SET :: Royal Blue Colour",
"description": "8 of your selected Fragrances from our Classic Line in an overwhelmingly unique Royal Blue wooden box.",
"volume": "",
"price": 0,
"category": "Assemblage",
"sub-category": "Assemblage",
"image": "http://192.168.1.163/ramasaat/public/storage/images/Products/deb955bd41baac2e98ee026c28734fb1.jpg"
},
.
.
.
],
"num_item": 3,
===============> "box": [
{
"id": 1,
"title": "MAYYAS",
"description": "An unmistakable presence and a charming aura of musk with an oriental flair. This fragrance merges a mixture of contrasting scents flawlessly and is full of mystery and charisma.",
"price": 990,
"image": "http://192.168.1.163/ramasaat/public/storage/images/Products/07c44b5a8fea99804ac57520103f755e.jpg"
},
.
.
.
.
]
}
【问题讨论】:
-
显示你使用的结构。
-
打印
error实例而不是error.localizedDescription。它会准确地告诉你哪里出了问题。 -
可以为您做与“相关”相同的事情
-
@vadian 很棒的人.....我用你的回答解决了这个问题