ESP8266 and JSON

Has anyone using the ESP8266 with the SDK had a go at using the JSON routines yet? I ask because I need to pass several MQTT messages to the board in a string.  I can of course do this the hard way, comma delimiter or similar, but it would be nice to try to use the JSON routines already in there. Anyone up for a simple example of use with 3 or 4 values passed to a string?

Facebooktwittergoogle_pluspinterestlinkedin

12 thoughts on “ESP8266 and JSON

    1. Thanks for that - actually when you download the SDK now, under DOCS most of the documents are there in English... the current manual is 1.3.0 (0.9.1 is very old now).

  1. Does anybody have some sample code of using the JSON from the SDK? I have a hard time to understand how you have to use the SDK JSON library. The IoT demo example is webserver based, but I use TuanPMT's MQTT code and like to exchange JSON messages between my ESP devices and my central system.

    1. Join the club Sweetpants - I've looked at the SDK several times and when it comes to the JSON implementation it has me completely lost. We could do with some simple starter examples...

  2. This is code from the SDK IoT example, but it's very complicated (for me at least) to understand what is done there. If you can explain, please do

  3. Did you guys ever manage to work with JSON? I tried simplifying the code in IoT but haven't got any success as yet. Here's what I have been doing so far (as understood from IoT Demo):

    1) In user init, start a tcp connection and start receiving.
    2) Parse incoming data in web server receive and call json_send.
    3) Call json_ws_send, this in turn calls the JSON callback function which has set and get methods as defined below:

    LOCAL struct jsontree_callback wifi_connect_ap_callback = JSONTREE_CALLBACK(connect_ap_get, connect_ap_set);

    JSONTREE_OBJECT(ap_setting, JSONTREE_PAIR("ssid", &wifi_connect_ap_callback), JSONTREE_PAIR("password", &wifi_connect_ap_callback));
    JSONTREE_OBJECT(wifi_tree, JSONTREE_PAIR("ap_details", &ap_setting));

    But my problem is that json tree callback never calls the connect_ap_set ( which supposedly extracts the values from json tree to variable) and then I am just printing them out.

    This is where I have run out of luck and dont seem to make any further headway.

    1. Hi Jan, Thanks for sharing your code. I will take a look at it when i'm back from holiday. At the moment I use a simple sprintf to format a JSON string and JasmineJSON to parse a JSON string, but I want to use the SDK JSON. This is a nice start

  4. hey guys, still no JSON sdk demos?
    I want to encode a json and send it via post request to my server.

Comments are closed.