Manipulation of json

Guest #7240917
Rate this post
• ▲ useful
▼ not useful
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
Rate this post
• ▲ useful
▼ not useful
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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.