Manipulation of json

Guest #7240917
Test schrieb:
> I want to read it in an array and add one pair [7,8].

You can write a simple JSON parser that does just that. Or you use a 
general JSON parsing library and construct your data structure with it. 
I guess adding the additional pair does not require any JSON business.

KR, Sebastian
Guest #7241012
Hello i tried it
1
#include <iostream>
2
#include "ArduinoJson.h"
3

4
int main() {
5
 
6
  StaticJsonDocument<300> doc;
7

8
  char json[] =
9
      "[[48.756080,2.302038],[48.756080,2.302038]]";
10

11

12
  DeserializationError error = deserializeJson(doc, json);
13

14

15
  if (error) {
16
    std::cerr << "deserializeJson() failed: " << error.c_str() << std::endl;
17
    return 1;
18
  }
19

20
  
21
  double longitude = doc[0];
22

23
  // Print values.
24
    std::cout << longitude << std::endl;


But the output is 0. WHat is wrong??

Reply

A question of your own? This thread is over 4 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.