Top 50 JSON Interview Questions with Answers

JSON Interview Questions with Answers
  1. What does JSON stand for?
    a) JavaScript Object Notation
    b) Java Syntax Object Notation
    c) JSON Object Notation
    d) None of the above

Answer: a) JavaScript Object Notation

  1. What is JSON used for?
    a) Data interchange format
    b) JavaScript plugin
    c) Code execution
    d) HTML markup

Answer: a) Data interchange format

  1. Which of the following data types can be used in JSON?
    a) Strings
    b) Numbers
    c) Booleans
    d) All of the above

Answer: d) All of the above

  1. What is the maximum depth limit in JSON?
    a) There is no limit
    b) 10 levels
    c) 100 levels
    d) 1000 levels

Answer: a) There is no limit

  1. Which of the following is NOT a valid JSON value?
    a) Null
    b) Undefined
    c) Object
    d) Array

Answer: b) Undefined

  1. What does the toJSON() method do?
    a) Converts a JSON string into an object
    b) Converts an object into a JSON string
    c) Parses a JSON file
    d) None of the above

Answer: b) Converts an object into a JSON string

  1. Which method is used to parse JSON?
    a) parseJSON()
    b) parse()
    c) fromJSON()
    d) toJSON()

Answer: b) parse()

  1. What is JSONP used for?
    a) Cross-domain requests
    b) Client-side validation
    c) Server-side scripting
    d) None of the above

Answer: a) Cross-domain requests

  1. Which symbol represents the start and end of a JSON object?
    a) {}
    b) []
    c) ()
    d) <>

Answer: a) {}

  1. Which symbol separates the key and value pair in a JSON object?
    a) :
    b) ;
    c) ,
    d) |

Answer: a) :

  1. What is the MIME type for JSON?
    a) application/javascript
    b) application/xml
    c) application/json
    d) text/json

Answer: c) application/json

  1. Which JavaScript method is used to stringify an object into JSON format?
    a) toJSONString()
    b) parse()
    c) stringify()
    d) fromJSON()

Answer: c) stringify()

  1. Which of the following is NOT a valid JSON data type?
    a) Decimal
    b) String
    c) Number
    d) Object

Answer: a) Decimal

  1. Which of the following is used to represent arrays in JSON?
    a) {}
    b) []
    c) ()
    d) <>

Answer: b) []

  1. Which of the following is NOT a valid way to create a JSON object?
    a) var obj = { name: “John”, age: 30 };
    b) var obj = new Object();
    obj.name = “John”;
    obj.age = 30;
    c) var obj = {“name”: “John”, “age”: 30};
    d) var obj = [ “name”: “John”, “age”: 30];

Answer: d) var obj = [ “name”: “John”, “age”: 30];

  1. What is JSON Schema used for?
    a) To validate JSON data
    b) To convert JSON to XML
    c) To create JSON objects
    d) None of the above

Answer: a) To validate JSON data

  1. Which of the following is NOT a valid JSON Schema data type?
    a) integer
    b) boolean
    c) real
    d) string

Answer: c) real

  1. What is JSON-RPC used for?
    a) Remote procedure calls
    b) Server-side scripting
    c) Client-side validation
    d) None of the above

Answer: a) Remote procedure calls

  1. What is JSON-B used for?
    a) Serializing Java objects into JSON
    b) Parsing JSON data into Java objects
    c) Validating JSON data
    d) None of the above

Answer: a) Serializing Java objects into JSON

  1. What does the @JsonIgnore annotation do in JSON-B?
    a) Excludes a field from serialization
    b) Includes a field in serialization
    c) Validates a field value
    d) None of the above

Answer: a) Excludes a field from serialization

  1. What is JSON-LD used for?
    a) To embed context data within JSON
    b) To retrieve data from external sources
    c) To create JSON objects
    d) None of the above

Answer: a) To embed context data within JSON

  1. Which method is used to format JSON data for readability?
    a) json_format()
    b) pretty_print()
    c) format()
    d) None of the above

Answer: b) pretty_print()

  1. Which of the following is valid JSON syntax?
    a) { “name”: “John”, “age”: 30, };
    b) { name: “John”, age: 30 }
    c) {“name”: “John”, “age”: 30 }
    d) None of the above

Answer: c) {“name”: “John”, “age”: 30 }

  1. Which of the following characters is NOT escaped in JSON?
    a) Backspace
    b) Form feed
    c) Double quote
    d) Single quote

Answer: d) Single quote

  1. What is the JavaScript method used to evaluate a JSON string into an object?
    a) evalJSON()
    b) parseJSON()
    c) executeJSON()
    d) None of the above

Answer: b) parseJSON()

  1. Which of the following is NOT a property of the JSON object in JavaScript?
    a) JSON.parse()
    b) JSON.stringify()
    c) JSON.serialize()
    d) None of the above

Answer: c) JSON.serialize()

  1. What does the reviver parameter do in the JSON.parse() method?
    a) It is used to parse nested JSON data
    b) It is used to modify the parsed data
    c) It is used to validate the parsed data
    d) None of the above

Answer: b) It is used to modify the parsed data

  1. Which of the following is a correct JSON data structure?
    a) {“name”: “John”, “age”: 30, “isMarried”: true}
    b) {name: “John”, age: 30, isMarried: true}
    c) {name: “John”, age: 30, isMarried: True}
    d) None of the above

Answer: a) {“name”: “John”, “age”: 30, “isMarried”: true}

  1. Which of the following is NOT a valid way to get a JSON array from a string?
    a) JSON.parse(string)
    b) eval(string)
    c) string.toJSON()
    d) None of the above

Answer: c) string.toJSON()

  1. What is the difference between JSON and XML?
    a) JSON is easier to read and parse
    b) XML is more suited for complex data structures
    c) JSON is more widely used
    d) All of the above

Answer: d) All of the above

  1. Which of the following is NOT a valid way to create a JSON object in Java?
    a) JSONObject obj = new JSONObject();
    obj.put(“name”, “John”);
    obj.put(“age”, 30);
    b) Map, Object> map = new HashMap<>();
    map.put(“name”, “John”);
    map.put(“age”, 30);
    JSONObject obj = new JSONObject(map);
    c) String json = “{\”name\”:\”John\”,\”age\”:30}”;
    JSONObject obj = new JSONObject(json);
    d) None of the above

Answer: d) None of the above

  1. What is the syntax to access a property in a JSON object?
    a) object.property
    b) object[“property”]
    c) object->property
    d) None of the above

Answer: b) object[“property”]

  1. Which of the following is used to store a JSON object in a cookie?
    a) JSON.parse()
    b) JSON.stringify()
    c) JSON.serialize()
    d) None of the above

Answer: b) JSON.stringify()

  1. What is JSON Web Token (JWT) used for?
    a) Authentication and authorization
    b) Data serialization
    c) Remote procedure calls
    d) None of the above

Answer: a) Authentication and authorization

  1. Which of the following is a valid JSON example of a nested object?
    a) {“name”:”John”,”address”:{“street”:”123 Main St”,”city”:”Anytown”,”state”:”CA”}}
    b) {“name”:”John”,”address”:[“123 Main St”,”Anytown”,”CA”]}
    c) {“name”:”John”,”address”:{“street”:”123 Main St”},”address”:{“city”:”Anytown”},”address”:{“state”:”CA”}}
    d) None of the above

Answer: a) {“name”:”John”,”address”:{“street”:”123 Main St”,”city”:”Anytown”,”state”:”CA”}}

  1. What is the syntax to access an element in a JSON array?
    a) array[index]
    b) array[“index”]
    c) array->index
    d) None of the above

Answer: a) array[index]

  1. Which of the following is NOT a valid way to create a JSON object in Python?
    a) data = {“name”: “John”, “age”: 30}
    json_data = json.dumps(data)
    b) data = json.load(“data.json”)
    c) data = json.loads(‘{“name”: “John”, “age”: 30}’)
    d) None of the above

Answer: b) data = json.load(“data.json”)

  1. Which of the following is NOT a valid way to create a JSON array in JavaScript?
    a) var array = [“John”, 30, true];
    b) var array = new Array(“John”, 30, true);
    c) var array = {
    0: “John”,
    1: 30,
    2: true
    };
    d) None of the above

Answer: c) var array = {0: “John”, 1: 30, 2: true}

  1. What is the difference between a JSON object and a JavaScript object?
    a) There is no difference
    b) A JSON object is a string, while a JavaScript object is an actual object
    c) A JavaScript object is defined using curly braces, while a JSON object is defined using quotes
    d) None of the above

Answer: b) A JSON object is a string, while a JavaScript object is an actual object

  1. What is JSON streaming used for?
    a) To reduce memory consumption when working with large data sets
    b) To validate JSON data
    c) To create JSON objects
    d) None of the above

Answer: a) To reduce memory consumption when working with large data sets

  1. What is the syntax to add a property to a JSON object?
    a) object.newproperty = value;
    b) object[“newproperty”] = value;
    c) object.addproperty(value);
    d) None of the above

Answer: b) object[“newproperty”] = value;

  1. Which of the following is NOT a valid way to create a JSON object in Ruby?
    a) data = {“name” => “John”, “age” => 30}
    json_data = JSON.dump(data)
    b) data = JSON.parse(‘{“name”: “John”, “age”: 30}’)
    c) data = JSON.load(‘data.json’)
    d) None of the above

Answer: c) data = JSON.load(‘data.json’)

  1. What does the JSON.stringify() method return?
    a) A JSON string
    b) A JSON object
    c) A JavaScript object
    d) None of the above

Answer: a) A JSON string

  1. Which of the following is a correct JSON data structure for an array of objects?
    a) [{“name”: “John”, “age”: 30}, {“name”: “Jane”, “age”: 25}]
    b) {0: {“name”: “John”, “age”: 30}, 1: {“name”: “Jane”, “age”: 25}}
    c) [“name”: “John”, “age”: 30], [“name”: “Jane”, “age”: 25]
    d) None of the above

Answer: a) [{“name”: “John”, “age”: 30}, {“name”: “Jane”, “age”: 25}]

  1. Which of the following is valid JSON syntax for an array of numbers?
    a) [1, 2, 3.14]
    b) [“1”, “2”, “3.14”]
    c) [“one”, “two”, “three”]
    d) None of the above

Answer: a) [1, 2, 3.14]

  1. What is the syntax to remove a property from a JSON object?
    a) delete object.property;
    b) object.remove(property);
    c) object[“property”] = null;
    d) None of the above

Answer: a) delete object.property;

  1. Which of the following is NOT a valid way to create a JSON object in C#?
    a) JObject obj = new JObject();
    obj.Add(“name”, “John”);
    obj.Add(“age”, 30);
    b) JObject obj = JObject.Parse(‘{“name”: “John”, “age”: 30}’);
    c) string json = “{\”name\”:\”John\”,\”age\”:30}”;
    JObject obj = JsonConvert.DeserializeObjectObject>(json);
    d) None of the above

Answer: d) None of the above

  1. What is the difference between JSON and BSON?
    a) JSON is more widely used
    b) BSON is more suited for complex data structures
    c) BSON is faster to parse
    d) All of the above

Answer: c) BSON is faster to parse

  1. What is the maximum length for a JSON string?
    a) 4GB
    b) 1GB
    c) 16MB
    d) 10MB

Answer: c) 16MB

  1. Which of the following is NOT a valid way to retrieve data from a JSON object?
    a) object.property
    b) object[“property”]
    c) object.getProperty()
    d) None of the above

Answer: c) object.getProperty()

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x