Convert Java Pojo to Json Object

      How To Convert Simple Java Pojo To Json Object in Java


Hello,

Here I am going to show you how to convert simple java pojo to json object by creating spring boot application using jockson-databind dependency.

Below I am going to give you steps to convert simple java pojo to json object.

Step1:-Create spring boot project :-
                                        
                                        
                                        
                                      

                                    

and add one more dependency that is jockson-databind this dependency is to convert java pojo to json object.

You will be get that that dependency in this link :-👇

Step 2:- Create simple pojo 

                                       

Step 3 :-Create one class and make the class as controller by giving @RestController annotation. And write one method , for the method give @GetMapping annotation and give mapping as '/student' ,Inside the method create object of the student class and pass the student first name , last name and email id and the return the list of students.

                                        

Step 4: Save the project and then run the project  and then open the browser in browser you need to give this URL then you get the list of student data in the form of json object.

        OUTPUT:-





You can refer this video:-
                                    

Related videos:-    



No comments

Powered by Blogger.