Best tactic to decode JSON data..

For general Flowcode discussion that does not belong in the other sections.
mnfisher
Valued Contributor
Posts: 1551
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 739 times

Re: Best tactic to decode JSON data..

Post by mnfisher »

As a test - try printing the string to the display.

ie - is it received incorrectly / converted incorrectly / sent as a float incorrectly...

Try and home in on the error.

Martin

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: Best tactic to decode JSON data..

Post by MJU20 »

As a test I already did both.
The string is shown like it should, the float doesn't have decimals.
My guess is that the ILI9488 treats the float as an integer..?
mnfisher wrote:
Mon Dec 09, 2024 3:45 pm
As a test - try printing the string to the display.

ie - is it received incorrectly / converted incorrectly / sent as a float incorrectly...

Try and home in on the error.

Martin

chipfryer27
Valued Contributor
Posts: 1607
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 565 times

Re: Best tactic to decode JSON data..

Post by chipfryer27 »

Hi

Could you perhaps print the number as a string?

Regards

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: Best tactic to decode JSON data..

Post by MJU20 »

Yes chipfryer27, but I need to calculate on the value so I need it as a number..

mnfisher
Valued Contributor
Posts: 1551
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 739 times

Re: Best tactic to decode JSON data..

Post by mnfisher »

It's a silly question/thought...

If you are using the ILI9488 PrintNumber to display the value then it will, indeed, get converted to am integer. PrintNumber takes an Int (so just 16 bits too) - and no digits after the point!

Martin

MJU20
Posts: 349
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 99 times
Been thanked: 69 times

Re: Best tactic to decode JSON data..

Post by MJU20 »

Oh my, you are right again.

My life is hell :-)

After all this time still make these mistakes, I was pretty sure that it took a Float too.
Now I really have a problem because I want to show the the number with only one decimal and need to calculate with this number.

I will work it out, but it should be great to have a component that shows all kinds of numbers, I know this is a lot of work...
Will figure it out.

Thank you again Martin!

mnfisher
Valued Contributor
Posts: 1551
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 138 times
Been thanked: 739 times

Re: Best tactic to decode JSON data..

Post by mnfisher »

We got there in the end....

Easily done - see my post this evening about trying to fit 16 bits of data into a byte :-( Sometimes it just needs a different pair of eyes.

You could have a macro PrintFloat - that takes a float x (and possibly number of digits after dp) and a position - convert x to a string using FloatToString$ - then print the string....

Martin

chipfryer27
Valued Contributor
Posts: 1607
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 565 times

Re: Best tactic to decode JSON data..

Post by chipfryer27 »

Hi

You can limit the number of decimal places

viewtopic.php?p=7248&hilit=number+of+de ... aces#p7248

You could use that for calculations, and then print.

Regards

Post Reply