How esp8266 parses json data
This article mainly introduces the relevant knowledge of how esp8266 parses json data, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this esp8266 article on how to parse json data, let's take a look.
# include void setup () {Serial.begin (115200); Serial.println ("here for testing the parsing of json data"); / / when defining DynamicJsonDocument objects, we need to define a size information + copy size const size_t capacity = JSON_OBJECT_SIZE (2) + 30; DynamicJsonDocument doc (capacity) / / the backslash of the json file to be parsed indicates that the coming quotation mark is not the String jsonstr = "{\" username\ ":\" admin\ ",\" pwd\ ": 123456}"; / / deserializes the data into the object deserializeJson (doc, jsonstr); / / gets the parsed data String nameStr = doc ["username"]. As (); int numberInt = doc ["pwd"]. As () / / output parsed data information through serial port monitor Serial.print ("usernameStr ="); Serial.println (nameStr); Serial.print ("pwdInt ="); Serial.println (numberInt);} void loop () {}
It is important to note that you need to install the library ArduinoJson first
Just install it in the Library Manager
Case effect
This is the end of the article on "how esp8266 parses json data". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how esp8266 interprets json data". If you want to learn more, you are welcome to follow the industry information channel.