Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:28:31+00:00 2026-06-09T11:28:31+00:00

aJsonObject* sBoard = aJson.createObject(); aJsonObject* sensorType = aJson.createObject(); aJsonObject* sBoard = aJson.createObject(); aJsonObject* sensorType

  • 0
  aJsonObject* sBoard = aJson.createObject();
  aJsonObject* sensorType = aJson.createObject();

  aJsonObject* sBoard = aJson.createObject();
  aJsonObject* sensorType = aJson.createObject();

  aJson.addItemToObject(sBoard, "name", aJson.createItem("SensorBoardOne"));
  aJson.addItemToObject(sBoard, "Sensor", sensorType);

  aJson.addNumberToObject(sensorType, "ph", 5.33);
  aJson.addNumberToObject(sensorType, "ec", 880);
  aJson.addNumberToObject(sensorType, "temp", 74.68);

  aJsonObject* ph = aJson.getObjectItem(sensorType, "ph");

  Serial.println(ph->valuefloat);

Serial.println(ph->valuefloat); returns 0.00. I have never dealt with C structs before and not sure if I setup the syntax correctly. My json structure seems fairly straight forward; however, I am not sure if I am accessing the correct creatObject() for the ph float value. What should I do to get the proper value of ph?

For further information about the aJSON library, please visit: http://interactive-matter.eu/blog/2010/08/14/ajson-handle-json-with-arduino/

EDIT new code:

  aJsonObject* sBoard = aJson.createObject();
  
  aJson.addItemToObject(sBoard, "name", aJson.createItem("SensorBoardOne"));
  
  aJson.addNumberToObject(sBoard, "ph", 5.33);
  aJson.addNumberToObject(sBoard, "ec", 880);
  aJson.addNumberToObject(sBoard, "temp", 74.68);
  
  aJsonObject* phValue = aJson.getObjectItem(sBoard, "ph");
  char* string = aJson.print(sBoard);
    if (string != NULL) {
      Serial.println(string); //prints out: {"name":"SensorBoardOne","ph":5.33000,"ec":880,"temp":74.68000}

    }

  Serial.println(phValue->valuefloat);

I ended up changing the json structure to more of a simpler structure. I felt there wasn’t a need for a another substructure due to the ram shortage of the arduino. After shortening the json structure I was able to successfully get the valuefloat of ph. I am still interested in figuring out the prior issue for future reference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:28:32+00:00Added an answer on June 9, 2026 at 11:28 am

    I just tried your code and found that you have declared both sBoard and sensorType twice at the beginning of the snippet.

    I removed it and I am getting the proper response “5.33”. This is the code that I am using after editing.

      aJsonObject* sBoard = aJson.createObject();
      aJsonObject* sensorType = aJson.createObject();
    
      aJson.addItemToObject(sBoard, "name", aJson.createItem("SensorBoardOne"));
      aJson.addItemToObject(sBoard, "Sensor", sensorType);
    
      aJson.addNumberToObject(sensorType, "ph", 5.33);
      aJson.addNumberToObject(sensorType, "ec", 880);
      aJson.addNumberToObject(sensorType, "temp", 74.68);
    
      aJsonObject* ph = aJson.getObjectItem(sensorType, "ph");
    
      Serial.println(ph->valuefloat);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this propery in my entity class: @Column(name=avatar,nullable=false,length=1000) String getAvatarData() { return new
I am using a JSONObject in order to remove a certin attribute I don't
This answer seems to show how to make a JSONObject. NSString *jsonString = @[{\id\:
I have a class like so: [JsonObject(MemberSerialization.OptIn)] public class foo { [JsonProperty(name_in_json)] public string
I´ve got a controller which gets an JsonObject from a POST method, parses it
I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in
I tried to get an answer from server and conver it to JSONObject .
I'm checking if an object in a JSON string exists using this: JSONObject json
i have a class extends asynctask private class taskMK extends AsyncTask<Void,Void,JSONObject>{ String url; JSONObject
JSON Parser Class public class JSONParser { static InputStream is = null; static JSONObject

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.