3 ms·
JSON-API [0] does something like this but would require your JSON to be formatted according to their specification and would then need parsing at the receiving
by EspadaV9 10y ago
JSON-API [0] does something like this but would require your JSON to be formatted according to their specification and would then need parsing at the receiving end. You would end up having some JSON like this
{
"data": [{
"type": "item",
"id": "123",
"attributes": {
"foo": "foo bar",
},
"relationships": {
"bar": {
"data": {
"type": "bar",
"id": "abc"
}
}
}
}, {
"type": "item",
"id": "456",
"attributes": {
"foo": "not foo bar",
},
"relationships": {
"bar": {
"data": {
"type": "bar",
"id": "abc"
}
}
}
}],
"included": [{
"type": "bar",
"id": "abc",
"attributes": {
"desc": "some really long data",
"other": "lots more data"
}
}]
}
This will initially increase the size of the JSON but depending on the number of relationships and the amount of data within them it could end up saving data.
As others have said you could just enabled gzip and leave it at that.
0: http://jsonapi.org/ http://jsonapi.org/