How to digest JSON data posted by http client to ESP32 Web Server?
Posted: Mon Oct 07, 2019 9:55 pm
Hi, My ESP32 WebServer sends a HTML page to a client browser. Customer fills the form and submits.
Client browser posts form data using a
var jsonFormInfo = JSON.stringify({ contruct type.
Data arrives at ESP32 Web server as the console printout below.
I am getting all the data I need (SEE BOLD TEXT below), my ESP32webServer gets JSON from a web browser but, so far, I am unable to get to the JSON data on the ESP32 side.
My Problem is:
Get to the JSON data arriving from the browser.
What is displayed at the ESP32 console when submit is clicked at the client browser:
CONSOLE PRINTOUT STARTS HERE:
New Client.
GET /?wifissid=myssid&wifiPass=mypass&delayPrimFoto=&delayEntreFotos=&timeGMT=2&smtpServer=&smtpUser=&smtpPass=&emailto=&emailTitle=&emailMessage=&ftpServer=&ftpUser=&ftpPass= HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Linux; Android 9; Mi A2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36 EdgA/42.0.4.3928
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7
Client disconnected.
CONSOLE PRINTOUT ENDS HERE:
Note: most variables came out empty because I only typed wifissid and wifiPass.
By the way:
Related libraries I am using and related commands:
#include <WiFiClientSecure.h>
WiFiServer server(80);
Based on my research I believe I need:
#include "AsyncJson.h"
#include "ArduinoJson.h"
But still do not know how to match the JSON data that arrives from customer browser on it.
Assistance welcome
Paulo
Client browser posts form data using a
var jsonFormInfo = JSON.stringify({ contruct type.
Data arrives at ESP32 Web server as the console printout below.
I am getting all the data I need (SEE BOLD TEXT below), my ESP32webServer gets JSON from a web browser but, so far, I am unable to get to the JSON data on the ESP32 side.
My Problem is:
Get to the JSON data arriving from the browser.
What is displayed at the ESP32 console when submit is clicked at the client browser:
CONSOLE PRINTOUT STARTS HERE:
New Client.
GET /?wifissid=myssid&wifiPass=mypass&delayPrimFoto=&delayEntreFotos=&timeGMT=2&smtpServer=&smtpUser=&smtpPass=&emailto=&emailTitle=&emailMessage=&ftpServer=&ftpUser=&ftpPass= HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Linux; Android 9; Mi A2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36 EdgA/42.0.4.3928
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7
Client disconnected.
CONSOLE PRINTOUT ENDS HERE:
Note: most variables came out empty because I only typed wifissid and wifiPass.
By the way:
Related libraries I am using and related commands:
#include <WiFiClientSecure.h>
WiFiServer server(80);
Based on my research I believe I need:
#include "AsyncJson.h"
#include "ArduinoJson.h"
But still do not know how to match the JSON data that arrives from customer browser on it.
Assistance welcome
Paulo