bblanchon / ArduinoJson

📟 JSON library for Arduino and embedded C++. Simple and efficient.
https://arduinojson.org
MIT License
6.69k stars 1.12k forks source link

Weird symbols for JsonObject #366

Closed fabiosoft closed 7 years ago

fabiosoft commented 7 years ago

I encode the json like this:

  DynamicJsonBuffer jsonBuffer;
  JsonObject& ack = jsonBuffer.createObject();
  ack[F("id")] = Discovery::getChipId_hex();
  ack[F("ssid")] = WiFi.SSID();
  ack[F("localip")] = WiFi.localIP().toString();
  ack[F("mac")] = WiFi.macAddress();

  int len = ack.measureLength();
  char buffer[len];
  ack.printTo(DEBUG_SERIAL);
  ack.printTo(buffer, ack.measureLength());

But instead to get printed this:

{"id": "xxxxx","ssid": "fabio_link_fast","localip": "192.168.1.106","mac": "XX:XX:XX:XX:XX:XX"}

I get

{"\bd":"\4\c3\34\4","ss\bd":"\c\fb\bo_l\bnk_\c\fst","lo\4\fl\bp":"1\32.168.1.106","m\f\4":"XX:XX:\3:XX"

What is this?? How to solve?

bblanchon commented 7 years ago

Even if that's not the cause of your problem, I highly recommend not to use flash strings with ArduinoJson (at least not now, see #76).

I tried your code and it works. Did you show all the relevant code?

See:

bblanchon commented 7 years ago

@fabiosoft, any progress?