interactive-matter / aJson

aJson is an Arduino library to enable JSON processing with Arduino. It easily enables you to decode, create, manipulate and encode JSON directly from and to data structures.
http://interactive-matter.org/2010/08/ajson-handle-json-with-arduino/
566 stars 136 forks source link

Updating a boolean value #66

Closed lasselukkari closed 9 years ago

lasselukkari commented 9 years ago

I was wondering why the boolean type has been split to aJson_False and aJson_True?

Because of this updating a boolean value may work in an unexpected way.

For example if I update a boolean value directly like this

aJson.getObjectItem(user, "registered")->valuebool = false; // was true before

and the print the obeject it still prints out as "true" because the printValue function only checks for the type and not the actual value.

I have created a fork where the values have been combined to a single type, but I didn't create a pull request yet because I think it's possible that I have just misunderstood something obvious.

interactive-matter commented 9 years ago

hmm, checking the my code at this point - could be rubbish - do not get my head around the fact Why there is aJson_False and aJson_True … could have been an oversimplification. I think it is better to solve the root cause, isn't it? like removing aJson_False and aJson_True for aJson_Bool or so - but that would be a bigger API change …

lasselukkari commented 9 years ago

Do you want me to create a pull request? I have the changes ready here: https://github.com/lasselukkari/aJson/commit/2e3f000f1bc912f5e0cb7dbe3e63368caaef6360

interactive-matter commented 9 years ago

Excellent! yes, please