JSON Tutorial in 36 Minutes
JSON Tutorial in 36 Minutes

In this video, we are going to learn all the concepts of JSON in one video step by step.

JSON Tutorial in 36 minutes | JSON Crash Course | Hindi

#JSON #CodeWithDurgesh

Telegram Link for Doubt: https://t.me/learncodewithdurgesh


Javascript Code

let student = {
  name: "durgesh",
  age: 20,
};

let str = '{"name":"durgesh","age":20}';

let ans = JSON.stringify(student);
console.log(ans);

let ob = JSON.parse(str);
console.log(ob);

Java Code

Note : Add GSON dependency First then use java code.

import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        System.out.println("Hello java , i am here to check json");

        Student student = new Student("Durgesh", "6576521626", "Delhi", 894556L);
        Student student1 = new Student("Uttam", "6576521626", "Delhi", 894556L);

        List<Student> list = new ArrayList<>();
        list.add(student);
        list.add(student1);

        Gson gson = new Gson();
        String str = gson.toJson(student);
        
        String str1 = gson.toJson(list);

        System.out.println(str);
        System.out.println(str1);

    }
}