JSON TO JAVA POJA
JSON TO JAVA POJO
what is JSON?
- JSON is the JavaScript Object Notation
- It's really just lightweight data format for storing and exchanging data,it just plain text
- Really nice thing about JSON is language independent,It is not just for JavaScript.
- We can use JSON with any programming languages like Java,C#,Python,Ruby etc
See Here is a simple JSON example:-
{
"id": 14,
"firstName": "Mario",
"lastName": "Rossi",
"active": true
}
2.Then create the class inside the package by the name Student
- In JSON curly braces is used to define object.Object members are name value pairs.
- Name value pair are delimited by colons.
- In the above example id is the name 14 is the value.
- Name is always in double quotes.
- values can be numbers,strings,boolean value, arrays and also it can have nested JSON object.
what is data binding?
Data binding is the process of converting JSON to JAVA POJO or converting JAVA POJO to JSON object
this process is called data binding.
To convert JSON to Java POJO or Java POJO to JSON we need this maven dependency:
One simple example to convert JSON to JAVA POJO:-
See here how I will convert this JSON object to JAVA POJO.
Step 1:First Create Spring boot project in Spring tool suite by the name JsontoJavapoja.
2.Then create the class inside the package by the name Student
Inside the Student Class write this code.
Inside the main method write this code.
Leave a Comment