JSON library truncating decimals

I am using the Arduino_JSON.h library to decode an incoming mqtt json string. The incoming data looks like: {"shutdown":0,"extra":0,"geolat":33.11111,"geolong":-84.11111} and I use the code below to extract the individual variables and their values:

JSONVar myObject = JSON.parse(commandresponse.c_str());
  commandshutdown = myObject["shutdown"];
  commandgeofence = myObject["extra"];
  double latitudefromweb = myObject["geolat"]; 
  double longitudefromweb = myObject["geolong"];

But I print the latitude and see it has been rounded significantly by this code. I read 33.11
how can I avoid this rounding?

Are you sure it is the JSON library and not the print function?

What do you see when you try the following?

Serial.print(latitudefromweb, 4);
1 Like

You are correct here if I use Serial.print(latitudefromweb, 4); I see 4 decimals

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.