#include <ArduinoJson.h>
DynamicJsonDocument doc(1024);
String studentName;
String studentId;
String course;
byte Semester;
byte arrear;
float percentage;
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop()
{
{ while (Serial.available()) {
String jsonOutput = Serial.readString();
Serial.print(jsonOutput);
//get a json data using Serial.readString() function
DeserializationError error = deserializeJson(doc, jsonOutput);
if (error)
{
Serial.print("Parsing failed: ");
Serial.println(error.c_str());
return;
}
studentName = doc["Student_name"].as<String>();
studentId = doc["Student_id"].as<String>();
course = doc["Course"].as<String>();
Semester = doc["Semester"];
arrear = doc["No of Arrears"];
percentage = doc["Percentage"];
Serial.println(studentName);
Serial.println(studentId);
Serial.println(course);
Serial.println(Semester);
Serial.println(arrear);
Serial.println(percentage);
}
}
}