您好我已经构建了一个Web应用程序以及一个移动应用程序,我的应用程序有几个返回JSON数据的API。我目前正与另一位想要使用该数据的开发人员合作。这是数据样本:
{
"categories": [
{
"id": 6,
"name": "Gospel",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/LHmKGd9nzrP7PB6X/gospel-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/LHmKGd9nzrP7PB6X/gospel-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/LHmKGd9nzrP7PB6X/gospel-75x62.jpg"
],
"slug": "gospel",
"event_count": 0
},
{
"id": 7,
"name": "Musicals",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/wTLvRXZeWSV5PVWZ/musicals-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/wTLvRXZeWSV5PVWZ/musicals-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/wTLvRXZeWSV5PVWZ/musicals-75x62.jpg"
],
"slug": "musicals",
"event_count": 0
},
{
"id": 8,
"name": "Comedy",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Ji95h2RowbxMf3QZ/comedy-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Ji95h2RowbxMf3QZ/comedy-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Ji95h2RowbxMf3QZ/comedy-75x62.jpg"
],
"slug": "comedy",
"event_count": 0
},
{
"id": 9,
"name": "Drama And Theatre",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/HQ9c76O9kxQ3qVjq/drama-and-theatre-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/HQ9c76O9kxQ3qVjq/drama-and-theatre-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/HQ9c76O9kxQ3qVjq/drama-and-theatre-75x62.jpg"
],
"slug": "drama-and-theater",
"event_count": 0
},
{
"id": 10,
"name": "Tours",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/K6m4kRnEmMS927Sd/tours-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/K6m4kRnEmMS927Sd/tours-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/K6m4kRnEmMS927Sd/tours-75x62.jpg"
],
"slug": "tours",
"event_count": 1,
"events": [
{
"id": 6,
"category_id": 10
}
]
},
{
"id": 11,
"name": "Sports",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Qg8d5Xy5ySr3BOSZ/sports-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Qg8d5Xy5ySr3BOSZ/sports-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/Qg8d5Xy5ySr3BOSZ/sports-75x62.jpg"
],
"slug": "sports",
"event_count": 0,
"events": []
},
{
"id": 12,
"name": "Cinema",
"thumbs": [
"http://xxxxxxxxxx.com/_uploads/2015-12-09/zkKPVrBjiryUKSKF/cinema-300x250.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/zkKPVrBjiryUKSKF/cinema-150x125.jpg",
"http://xxxxxxxxxx.com/_uploads/2015-12-09/zkKPVrBjiryUKSKF/cinema-75x62.jpg"
],
"slug": "cinema",
"event_count": 0
}
]
}
现在根据他的说法,这个数据太复杂了,不得不多次解析,他使用ruby。然而,在PHP和Javascript中,情况并非如此。我同时使用laravel和AngularJS。我通过有效性检查器运行此JSON,它确实有效。我现在想了解一些这方面的信息,这个JSON有什么问题,它能以任何方式变得更简单吗?
答案 0 :(得分:2)
不,JSON是一种相对简单的数据结构。在幕后,它与YAML具有相同的数据结构,只有不同的语法。它是名称 - 值对和数组的任意组合,其中任何元素本身都可以是名称 - 值对或数组的一部分。简单。
其他开发者有两个选择:
似乎只有第一种选择才有可行。也许他应该在这里发布他的问题?