GithubHelp home page GithubHelp logo

Comments (6)

bblanchon avatar bblanchon commented on September 26, 2024

Let me sum this up.

You expect:

JsonArray<3> json;
json.add(0.0f);

to generate

[0.0]

but instead you get

[0]

I that what you're saying?

from arduinojson.

bblanchon avatar bblanchon commented on September 26, 2024

I'm not sure if it makes sense.
The JSON format makes no difference between integers and floats, it only has a "number" type.
(see http://json.org/)

I tried in Python, and it printed "[0.0]".
I tried in JavaScript, and it printed "[0]".

So it means, that you can easily find both flavors in the nature.

Anyway, I don't see any disadvantage but adding 2 bytes in the JSON.
I fixed this in the Issue22 branch.
Please give it a try.

from arduinojson.

Slechtvalk avatar Slechtvalk commented on September 26, 2024

Hello,

Op 20 sep 2014, om 18:26 heeft Benoît Blanchon het volgende geschreven:

Let me sum this up.

You expect:

JsonArray<3> json;
json.add(0.0f);

to generate

[0.0]

but instead you get

[0]

I that what you're saying?

That is correct. When encoding a JSON message, a float 0 should be encoded as 0.0 and an integer 0 as 0. I don't know if that is feasible, but it would make decoding a lot easier.

Ewout Boks


Reply to this email directly or view it on GitHub.

from arduinojson.

Slechtvalk avatar Slechtvalk commented on September 26, 2024

Op 20 sep 2014, om 18:50 heeft Benoît Blanchon het volgende geschreven:

I'm not sure if it makes sense.
The JSON format makes no difference between integers and floats, it only has a "number" type.
(see http://json.org/)

I tried in Python, and it printed "[0.0]".
I tried in JavaScript, and it printed "[0]".

So it means, that you can easily find both flavors in the nature.

Anyway, I don't see any disadvantage but adding 2 bytes in the JSON.
I fixed this in the Issue22 branch.
Please give it a try.

Okay, I'll take a look at it.

Ewout


Reply to this email directly or view it on GitHub.

from arduinojson.

bblanchon avatar bblanchon commented on September 26, 2024

Did it solve your problem ?

from arduinojson.

Slechtvalk avatar Slechtvalk commented on September 26, 2024

Hi,

I tried the #22 version, and it fixed the problem :

16:41:07: Arduino JSON test.
16:41:07: json object[0] = {"sensornaam":"Hoogtesensor","waarde":[0,true,0.0]}
16:41:07: json object[1] = {"sensornaam":"Hoogtesensor","waarde":[1,false,42.34]}
16:41:07: json object[2] = {"sensornaam":"Hoogtesensor","waarde":[2,true,84.68]}
16:41:07: json object[3] = {"sensornaam":"Hoogtesensor","waarde":[3,false,127.02]}
16:41:07: json object[4] = {"sensornaam":"Hoogtesensor","waarde":[4,true,169.36]}
16:41:07: Totale strong om te parsen is :{"sensornaam":"Hoogtesensor","waarde":[0,true,0.0]} {"sensornaam":"Hoogtesensor","waarde":[1,false,42.34]} {"sensornaam":"Hoogtesensor","waarde":[2,true,84.68]} {"sensornaam":"Hoogtesensor","waarde":[3,false,127.02]} {"sensornaam":"Hoogtesensor","waarde":[4,true,169.36]}
16:41:07: wxJSON parsing : [sensornaam] = null
16:41:07: wxJSON parsing[0] : [stand] = 1
16:41:07: wxJSON parsing[0] : [waarde] = 0.000000
16:41:07: wxJSON parsing[1] : [stand] = 0
16:41:07: wxJSON parsing[1] : [waarde] = 42.340000
16:41:07: wxJSON parsing[2] : [stand] = 1
16:41:07: wxJSON parsing[2] : [waarde] = 84.680000
16:41:07: wxJSON parsing[3] : [stand] = 0
16:41:07: wxJSON parsing[3] : [waarde] = 127.020000
16:41:07: wxJSON parsing[4] : [stand] = 1
16:41:07: wxJSON parsing[4] : [waarde] = 169.360000
16:41:07: Arduino JSON test einde

As you can see the first created object has a value '0.0' inserted into it, instead of 0 . As a result, wxJSON does not assert anymore on parsing the value.

Thanks!

Ewout Boks

Op 27 sep 2014, om 16:10 heeft Benoît Blanchon het volgende geschreven:

Did it solve your problem ?


Reply to this email directly or view it on GitHub.

from arduinojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.