Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library version able to parse float lacking decimal? #726

Closed
mkarlesky opened this Issue Apr 27, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@mkarlesky
Copy link

mkarlesky commented Apr 27, 2018

We're using ArduinoJson on an AVR platform for the ATmega2560. Our release code is built with avr-gcc 4.9.4. Our unit tests are cross compiled in a Linux environment using gcc 4.9.4. We're a number of versions behind on the ArduinoJson library itself at version 5.5.1.

We hit a bump today and are trying to determine the best course of action. We discovered in our on-target release build and in our unit tests that a numeric JSON value lacking a decimal (e.g. 2 instead of 2.0) parsed as a float erroneously returns 0.

Experiments with the offending line of code using the latest version of ArduinoJson in Wandbox with our version of gcc suggests this is no longer a problem (assuming it truly was).

Questions:

  1. We searched through past issues and the FAQ but did not come across anything exactly as we are describing. Is it likely we're experiencing a failing of a much older version of the library?
  2. If so, what's the easiest way to fix this?
    1. Is there something we can implement while continuing to use version 5.5.1?
    2. Even versions near to 5.5.1 in age have significant changes. If we cannot fix this with 5.5.1 should we just zoom all the way ahead to 5.13.1? Any guidance on what sort of changes in our existing code we should expect upon making that update?
@bblanchon

This comment has been minimized.

Copy link
Owner

bblanchon commented Apr 28, 2018

Hi @mkarlesky,

More than 700 questions have been posted to this day and this is one of the most surprising 😄
On the one hand, you give a very precise description of your setup; but on the other hand, you forgot to provide the most important pieces of information:

  1. Why are you stuck to ArduinoJson 5.5.1?
  2. What is the code for the unit test?

I don't remember why this version behaved that way, but it sure treated floats and integer differently than today.

In any case, I strongly recommend that you upgrade to version 5.13.
Have a look at the changelog, especially at the breaking changes.

Regards,
Benoit

@bblanchon bblanchon added the question label Apr 28, 2018

@mkarlesky

This comment has been minimized.

Copy link
Author

mkarlesky commented Apr 28, 2018

We have a number of embedded devices in use whose application code is built with ArduinoJson 5.5.1. We've written a lot of code around ArduinoJson 5.5.1, and it's been in use for years at this point. A new use case developed recently where we began introducing more floating point values into the JSON being processed. Things started breaking. To our surprise we identified it being the absence of a decimal point in numeric entries in the JSON.

We were hesitant to update to a far newer version of the library without first consulting the author. Updating to the new library could be quite a significant amount of coding work plus updating deployed systems and potentially introduce unforeseen instabilities. We know 5.5.1 and apart from this decimal issue we are quite comfortable with it. We did, in fact, consult the Changelog, but we weren't able to determine if the changes between 5.5.1 and 5.13.1 fixed our issue or what kind of work would be necessary to update existing code.

So… I just now went ahead and rebuilt our code and re-ran unit tests with 5.13.1 as an experiment. To my great surprise and relief the problem is solved, no code rewrites were needed, and only a single compiler flag change was necessary for the release build! We still need to do the appropriate packaging, documentation, and validation testing before deployment, but I am so very pleased to see these results.

Some thank you's:

  1. For your quick reply.
  2. For the ArduinoJson library itself. You've clearly done a tremendous amount of very good work. In fact, the existence of ArduinoJson was a key input into the decision and design process for our system's architecture a couple years ago.

We can close this issue.

Thank you again.

@bblanchon

This comment has been minimized.

Copy link
Owner

bblanchon commented Apr 30, 2018

Hi Mike,

I'm glad the upgrade went fine.
Thank you very much for the kind words.

Regards,
Benoit

@bblanchon bblanchon closed this Apr 30, 2018

Repository owner locked and limited conversation to collaborators Sep 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.