Author Topic: Arduino Json library query; Atmega2560  (Read 578 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.takniki

  • Frequent Contributor
  • **
  • Posts: 357
Arduino Json library query; Atmega2560
« on: October 14, 2016, 05:16:14 pm »
For JSOn format using this library: https://github.com/bblanchon/ArduinoJson

1. I have defined Json using:
    StaticJsonBuffer<80> jsonBuffer;
    JsonArray& array = jsonBuffer.createArray();

2. Now I keep on using add operator like as below & keep on adding values in array like this:
    array.add("Value");
    array.add(data[0]);

3. After one loop, I want to reinit the Json array index to 0 again. So that when I now add values , it should again start from index 0. How to do that?

4. Second question is how to know how much array size is filled in Json array at any point of time. This will help in case, intiially I will define a large array, now when I keep on adding values in it, in the end I want to know whats its size know. So that I can optimize the size of initially defined Json array.

In the end I have to send this JSON generated string on SIM800 on a known IP address & port number.
 

Offline FreddyVictor

  • Regular Contributor
  • *
  • Posts: 164
  • Country: gb
Re: Arduino Json library query; Atmega2560
« Reply #1 on: October 14, 2016, 07:17:25 pm »
Quote
3. After one loop, I want to reinit the Json array index to 0 again. So that when I now add values , it should again start from index 0. How to do that?
maybe try using: removeAt(size_t index)
Quote
4. Second question is how to know how much array size is filled in Json array at any point of time.
maybe keep a count when you add ?

there is some code at the top of this to get array size in bytes so perhaps could try something like that
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf