Use##Use JSON.##
(Building on Munificent's response, and largely in response to your concerns expressed elsewhere)
You've mentioned in another comment it stillconcern that JSON has the issue of wasting space naming elements, like XML. It doesn't.
JSON is built on two structures: name/value pairs (objects) and ordered lists of values (arrays).
You are complaining about objects whilst forgetting arrays exist XML is built only on name/value pairs.
Using mainly objectsIf you could dothink JSON relies on objects you've been reading JSON that's built to be self-descriptive and human-readable, like this (using octal digit pairs to represent single bytes):
{
"some": ...,
"data": ...,
"fields": ...,
"cars": [
{"name":"nissan""greg","num1""cost":8C,"num2""speed":FA,"num3""age":2A04,"num4""driverID":384FFFFF},
{"name":"holden""ole rustbucket","num1""cost":00,"num2""speed":00,"num3""age":042A,"num4""driverID":04FF54A9}
]
}
(You could end up with a byte with the value 2C, which a parser could mistake for a comma, but this isn't an issue if However you know the length of each field and so understand that the 2C is part of a value and not the markup)
Youalso have the option of dropping objects completely, howeverwriting it like this, asso long as you know where everything will be, and that the 4th (and so can look for index 4, rather than object "cars", to get your list of the main array is cars, etc):
{
[
...,
...,
...,
[["nissan"[["greg",8C,FA,2A04,384FFFFF],["holden"["ole rustbucket",00,00,042A,04FF54A9]],
...,
]
}
Does it get more concise than just having [
, ]
, ,
and your values?
Well, it does if you're willing to just save the whole thing asget closer and closer to a pure binary stream and forget about data formats altogether.
"cars":{"names":["greg","ole rustbucket"],"stream":8CFA04384FFFFF00002A04FF54A9}
or
[["greg","ole rustbucket"],8CFA04384FFFFF00002A04FF54A9]
Just don't shoot yourself in the leg by optimising too much.