I was wondering if someone knows of an API that can shorten the JSON. Usual JSON:
{
"posts": [
{
"id": "its-hard-to-forego-efficiency",
"date": "March 28, 2017",
"title": "It's Hard to Forego Efficiency",
"postedBy":{
"id":"1",
"name":"John Doe # 1",
"dateOfBirth":"12/12/2006"
}
},
{
"id": "2016-in-review",
"date": "January 6, 2017",
"title": "2016 in Review",
"postedBy":{
"id":"1",
"name":"John Doe # 1",
"dateOfBirth":"12/12/2006"
}
},
{
"id": "addressable-errors",
"date": "February 4, 2016",
"title": "Addressable Errors",
"postedBy":{
"id":"1",
"name":"John Doe # 1",
"dateOfBirth":"12/12/2006"
}
},
{
"id": "pure-ui",
"date": "July 13, 2015",
"title": "Pure UI",
"postedBy":{
"id":"1",
"name":"John Doe # 1",
"dateOfBirth":"12/12/2006"
}
},
{
"id": "ecmascript-6",
"date": "February 22, 2015",
"title": "ECMAScript 6",
"postedBy":{
"id":"2",
"name":"John Doe # 2",
"dateOfBirth":"12/12/2006"
}
},
{
"id": "7-principles-of-rich-web-applications",
"date": "November 4, 2014",
"title": "7 Principles of Rich Web Applications",
"postedBy":{
"id":"1",
"name":"John Doe # 1",
"dateOfBirth":"12/12/2006"
}
}
]
}
We can improve the JSON by moving the users into a sperate array.
{
"users": [
{
"id": "1",
"name": "John Doe # 1",
"dateOfBirth": "12/12/2006"
},
{
"id": "2",
"name": "John Doe # 2",
"dateOfBirth": "12/12/2006"
}
],
"posts": [
{
"id": "its-hard-to-forego-efficiency",
"date": "March 28, 2017",
"title": "It's Hard to Forego Efficiency",
"postedByUserId": 1
},
{
"id": "2016-in-review",
"date": "January 6, 2017",
"title": "2016 in Review",
"postedByUserId": 1
},
{
"id": "addressable-errors",
"date": "February 4, 2016",
"title": "Addressable Errors",
"postedByUserId": 1
},
{
"id": "pure-ui",
"date": "July 13, 2015",
"title": "Pure UI",
"postedByUserId": 1
},
{
"id": "ecmascript-6",
"date": "February 22, 2015",
"title": "ECMAScript 6",
"postedByUserId": 2
},
{
"id": "7-principles-of-rich-web-applications",
"date": "November 4, 2014",
"title": "7 Principles of Rich Web Applications",
"postedByUserId": 1
}
]
}