|
Maybe it's a monitor thing as the screenshot looks fine to me with the Royal Mail logo the only slightly difficult bit to read.
|
|
|
|
|
You need to get your eyes tested!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
|
|
@code-witch
Congratulations on your "Article of the month" win for last month! Well deserved!
Keep 'em coming.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks!
Real programmers use butterflies
|
|
|
|
|
Congrats, you legend! Which one was it?
|
|
|
|
|
|
JSON "object" fields can be in any order. They are not guaranteed to be in "schema order" or alphabetical/asciibetical order.
This makes it very difficult to query a JSON object without loading it into memory first.
Consider the following JSON:
{
"air_date": "2011-04-17",
"episode_number": 1,
"id": 224659,
"name": "The Fall of Sam Axe",
"overview": "The Fall of Sam Axe is a 2011 American television film based on the USA Network television series Burn Notice...",
"production_code": null,
"season_number": 0,
"show_id": 2919
}
Say I wanted to format a string like "S00E01 The Fall of Sam Axe"
Easy, right?
printf("S%02dE%02d %s\r\n",season_number,episode_number,name);
Where the three format vars come from the JSON fields of the same name.
The trouble is this: I don't know which order the fields come in. I can see they're alphabetical now, but the spec says I can't count on that.
So if I'm using a streaming pull parser over a forward only cursor I've got a bit of a problem.
One solution is to have the parser be able to skip to a field with a set of possible field names.
const char* fields[] = {"season_number","episode_number","name"};
while(jsonReader.skipToFields(fields,3,JsonReader::Siblings)) {
...
}
The trouble is implementing skipToFields() is extremely difficult because of the varying starting points. What happens in that while loop dictates where your cursor ends up, and finding the next fields from that is no joke. I don't keep a depth because certain operations like using the "All" axis cut right through the hierarchy and those searching/skipping functions only do partial parsing.
JSON is deceptively complicated.
Real programmers use butterflies
|
|
|
|
|
Please use QA to ask specific technical questions.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
That would be great, if I was asking a question. I'll look for the question mark in my post which I clearly put in there by mistake.
Real programmers use butterflies
|
|
|
|
|
I'd say that JSON is suitable in environments where reading the structure into memory is The Thing To Do.
If you cannot read the whole thing into memory, maybe JSON isn't for you
This, of course, assumes that JSON is suitable at all.
But for a general comment: The very idea of a tagged record structure is to be independent of ordering. If the ordering where fixed according to some schema, an array would probably be a better choice. Then you could omit the tags altogether, saving both space and processing.
|
|
|
|
|
trønderen wrote: If you cannot read the whole thing into memory, maybe JSON isn't for you
The entire world of IoT would scarcely exist online if that were the case.
Real programmers use butterflies
|
|
|
|
|
...and that might not be such a bad thing.
|
|
|
|
|
I'd be out of work.
Real programmers use butterflies
|
|
|
|
|
Somehow I imagine you could easily find something else!
|
|
|
|
|
But something I enjoy this much?
My core nature is not "software developer"
It's "builder"
I like to make things. The reason I got into software is when I was very young I was building simple digital circuits but i didn't have money to buy the neverending list of equipment and supplies to keep up the hobby, so I got into software, which required nothing upfront (at the time) but effort. I fell in love with it and just never stopped.
But ultimately I like to build. Under slightly different circumstances I could have been a metal fabricator and/or engineer.
The IoT stuff incorporates some of that physicality that I like.
Real programmers use butterflies
|
|
|
|
|
They're "key value pairs" ... no order implied. XML has paths. That's why XML is "more perfect".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
XML also does not impose order.
|
|
|
|
|
Well, obviously the user should be responsible for specifying the order of the desired fields and not you.
|
|
|
|
|
With JSON *nobody* gets to specify the order. That makes them suitable for putting in things like std::unordered_map, but not so great for sequential forward only queries.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: JSON is deceptively complicated.
Only because you're not using it as intended.
There's nothing that stops you from defining a new ordered JSON-standard. I mean, another standard is just what we need isn't it.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
I mean, I don't know that JSON wasn't *intended* for low memory environments, but I could get behind the idea that it wasn't designed for them.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: but I could get behind the idea that it wasn't designed for them
Fair enough.
I see it this way, JSON was intended to be used with Javascript. Javascript is anything but low memory! Intentional or not.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|