Working with JSON is crucial for modern Java applications, especially for web and network services.
Source Code
import org.json.JSONObject;
public class JsonExample {
public static void main(String[] args) {
String jsonString = "{"name":"John", "age":30, "city":"New York"}";
JSONObject obj = new JSONObject(jsonString);
String name = obj.getString("name");
System.out.println(name);
}
}