I need to post a big json to the nodemcu server which would be bigger than the ram's size

I am using esp8266werserver and arduinojson libraries. I know how to use arduinojson to parse huge json response from other servers by parsing the response as a stream using response.getstream() . I can reuse a small static buffer in the stack to parse the whole json in a loop which performs really well.

But when I use nodemcu as a server, I can't find any similar method in the ESP8266WebServer to allow me to process json response as a stream. All I can only do is to read the string file in server.arg("plain") which may crash as the string may get bigger than the ram.

Is there a quick and dirty workaround? I look at the source in parsing.cpp there is a readBytesWithTimeout method that seems to be responsible to actually parsing the response stream. I am wondering if I may override this function to do what I need but I don't know how.


1 Answer 1


The ESP8266WebServer library can process only a HTML-Form POST request of application/x-www-form-urlencoded or mulripart/ content type.

You could sent the JSON as multipart 'upload' to save it to file, but it would require to build the multipart format of the POST body.

If you want to process POST with application/json content type, you could make a simple web server implemented with WiFiServer.

  • oh I didn't think about simply using WiFiserver. Seems like a nice workaround. Thanks so much for the suggestion. Nov 14, 2018 at 13:46
  • But by the way what I will be missing if I use WiFiserver instead of the Esp8266webserver? Is the Esp8266webserver better optimised for the esp8266? Would like to know more about the trade off. Nov 14, 2018 at 13:48
  • 1
    it depends how much of ESP8266WebServer functionality you use. ESP8266WebServer only wraps WiFiServer with HTTP and HTML-Form processing
    – Juraj
    Nov 14, 2018 at 13:58
  • Then seems like I should really look into WiFiserver instead thanks so much for your help Juraj Nov 14, 2018 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.