Question

You are trying to parse a JSON string in Java using a library like org.json. import org.json.JSONObject; import org.json.JSONException; public class JsonParser {     public static void main(String[] args) {         String jsonString = "{'name': 'Alice', 'age': 30}"; // Potential bug here         try {             JSONObject jsonObject = new JSONObject(jsonString);             System.out.println("Name: " + jsonObject.getString("name"));         } catch (JSONException
e) {             System.err.println("JSON Parsing Error: " + e.getMessage());         }     } } What is the most likely error this Java code will encounter when trying to parse jsonString?

A NullPointerException because jsonString is not valid.
B JSONException because JSON requires double quotes for string literals and keys.
C ClassCastException because age is an integer, not a string.
D FileNotFoundException because the JSON is not from a file.
E No error, it will parse correctly.
Practice Next

Hey! Ask a query