JSON Interview Questions And Answers

[TOP 100] JSON Interview Questions And Answers

Latest JSON Interview Questions And Answers

JSON Interview Questions And Answers are as follows –

1) What does JSON stand for?

Answer: JSON stands for “JavaScript Object Notation”.

2) What is JSON?

Answer: JSON is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA.

3) What programming languages supported by JSON?

Answer: JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.

4) Is JSON is a language?

Answer: JSON is a data format. It could be classified as a language, but not a programming language. Its relationship to JavaScript is that it shares its syntax (more or less) with a subset of JavaScript literals.

5) What are the properties of JSON?

Answer: These properties make JSON an ideal data-interchange language.

JSON is built on two structures:

A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.

An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.

6) Why do we use JSON?

Answer: The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML.

7) What is JSON data?

Answer: JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. In JSON data is nothing but a information. It is used primarily to transmit data between a server and web application, as an alternative to XML.

8) What is the difference between XML and JSON?

Answer: The fundamental difference, which no other answer seems to have mentioned, is that XML is a markup language (as it actually says in its name), whereas JSON is a way of representing objects (as also noted in its name). This is what makes markup languages so useful for representing documents.

9) Why JSON format is better than XML?

Answer: JSON and XML used different formats. When compared both JSON is easy to write and use it applications then XML. The XML format can also be determined by the XML DTD or XML Schema (XSL) and can be tested.

The JSON a data-exchange format which is getting more popular as the JavaScript applications possible format. Basically this is an object notation array. JSON has a very simple syntax so can be easily learned.

10) Is JSON markup language?

Answer: JSON is like XML in that it is used to structure data in a text format and is commonly used to exchange data over the Internet. JSON is not a markup language. JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.

11) What is JSON Text?

Answer: A JSON text is a sequence of tokens formed from Unicode code points that conforms to the JSON value grammar. The set of tokens includes six structural tokens, strings, numbers, and three literal name tokens.

The six structural tokens:
[ U+005B left square bracket
{ U+007B left curly bracket
] U+005D right square bracket
} U+007D right curly bracket
: U+003A colon
, U+002C comma

These are the three literal name tokens:
true U+0074 U+0072 U+0075 U+0065
false U+0066 U+0061 U+006C U+0073 U+0065
null U+006E U+0075 U+006C U+006C

Insignificant whitespace is allowed before or after any token. Whitespace is any sequence of one or more of the following code points: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020). Whitespace is not allowed within any token, except that space is allowed in strings.

12) What is JSON Value?

Answer: A JSON value can be an object, array, number, string, true, false, or null.

13) What is JSON Syntax?

JSON syntax is derived from JavaScript object notation syntax. Data is in name/value pairs. Data is separated by commas. Curly braces hold objects. Square brackets hold arrays.

14) What is JSON Value?

Answer: In JSON, value holds some data. A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

Values in JSON must be one of the following data types:

  • a string
  • a number
  • an object (JSON object)
  • an array
  • a boolean
  • null

15) What is JSON Array?

Answer: An array structure is a pair of square bracket tokens surrounding zero or more values. An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).

The values are separated by commas. The JSON syntax does not define any specific meaning to the ordering of the values. However, the JSON array structure is often used in situations where there is some semantics to the ordering.

16) What is Number in JSON?

Answer: JSON Numbers – A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used. A number is a sequence of decimal digits with no superfluous leading zero.

It may have a preceding minus sign (U+002D). It may have a fractional part prefixed by a decimal point (U+002E). It may have an exponent, prefixed by e (U+0065) or E (U+0045) and optionally + (U+002B) or – (U+002D). The digits are the code points U+0030 through U+0039.

Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted.

17) What is JSON String?

Answer: A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.

A string is a sequence of Unicode code points wrapped with quotation marks (U+0022). All code points may be placed within the quotation marks except for the code points that must be escaped: quotation mark (U+0022), reverse solidus (U+005C), and the control characters U+0000 to U+001F. There are two-character escape sequence representations of some characters.

\” represents the quotation mark character (U+0022).
\\ represents the reverse solidus character (U+005C).
\/ represents the solidus character (U+002F).
\b represents the backspace character (U+0008).
\f represents the form feed character (U+000C).
\n represents the line feed character (U+000A).
\r represents the carriage return character (U+000D).
\t represents the character tabulation character (U+0009).

18) What is JSON object?

Answer: An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

19) What is JSON RPA Java?

Answer: JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML (so it is much faster).

20) What is a JSON parser?

Answer: JSON parser to parse JSON object and MAINTAIN comments. By using JSON, when receiving data from a web server, the data should be always in a string format. We use JSON.parse() to parse the data and it becomes a JavaScript object.

The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

21) Which browser provides native JSON support?

Answer: All modern browsers support native JSON encoding/decoding (Internet Explorer 8+, Firefox 3.1+, Safari 4+, and Chrome 3+). Basically, JSON.parse(str) will parse the JSON string in str and return an object, and JSON.stringify(obj) will return the JSON representation of the object obj.

22) What is the difference between JSON parse and JSON Stringify?

Answer: JSON.stringify() is to create a JSON string out of an object/array. They are the inverse of each other. JSON.stringify() serializes a JS object into a JSON string, whereas JSON.parse() will deserialize a JSON string into a JS object.

23) What is the MIME type of JSON?

Answer: The MIME media type for JSON text is application/json . The default encoding is UTF-8.

24) What is the use of JSON Stringify?

Answer: The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified, or optionally including only the specified properties if a replacer array is specified.

25) What does JSON parse do?

Answer: The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

26) What is serialization in Javascript?

Answer: The serialize() method creates a URL encoded text string by serializing form values. You can select one or more form elements (like input and/or text area), or the form element itself. The serialized values can be used in the URL query string when making an AJAX request.

27) What is Polyfill?

Answer: The JSON object is not supported in older browsers. We can work around this by inserting a piece of code at the beginning of your scripts, allowing use of JSON object in implementations which do not natively support it (like Internet Explorer 6) is called Polyfill.

28) What is toJSON() method in JOSN?

Answer: The toJSON() method returns a string representation of the Date object.

29) What is JSONP?

Answer: JSONP stands for JSON with Padding. JSONP is a method for sending JSON data without worrying about cross-domain issues. JSONP does not use the XMLHttpRequest object. JSONP uses the <script> tag instead.

30) What is the difference between JSON and JSONP?

Answer: JSONP is a simple way to overcome browser restrictions when sending JSON responses from different domains from the client. But the practical implementation of the approach involves subtle differences that are often not explained clearly. Here is a simple tutorial that shows JSON and JSONP side by side.

31) What is serialization and deserialization in JSON?

Answer: JSON is a format that encodes objects in a string. Serialization means to convert an object into that string, and deserialization is its inverse operation. When transmitting data or storing them in a file, the data are required to be byte strings, but complex objects are seldom in this format.

32) What is serialization of an object?

Answer: To serialize an object means to convert its state to a byte stream so that the byte stream can be reverted back into a copy of the object.

33) What is the use of JSON in Java?

Answer: The Java API for JSON Processing provides portable APIs to parse, generate, transform, and query JSON. JSON (JavaScript Object Notation) is a lightweight, text-based, language-independent data exchange format that is easy for humans and machines to read and write.

34) Why do we use JSON in PHP?

Answer: A common use of JSON is to read data from a web server, and display the data in a web page. This chapter will teach you how to exchange JSON data between the client and a PHP server.

35) What is JSON Formatter?

Answer: The JSON Formatter & Validator helps debugging JSON data by formatting and validating JSON data so that it can easily be read by human beings.

36) What is JSON Viewer?

Answer: JSON Viewer – Convert JSON Strings to a Friendly Readable Format.

37) What is JSON Validator?

Answer: The JSON Validator helps debugging JSON data by formatting and validating JSON data so that it can easily be read by human beings.

38) Why do we use JSON in Android?

JSON stands for JavaScript Object Notation.It is an independent data exchange format and is the best alternative for XML.

Android provides four different classes to manipulate JSON data. These classes are JSONArray,JSONObject,JSONStringer and JSONTokenizer.

39) Why do we use JSON in Python?

Answer: Python programming language is used to encode and decode JSON objects.

Python encode() function encodes the Python object into a JSON string representation.

Python decode() function decodes a JSON-encoded string into a Python object.

40) What is JSON in JavaScript?

Answer: JSON is derived from the JavaScript programming language, it is a natural choice to use as a data format in JavaScript. JSON, short for JavaScript Object Notation.

41) What is JSON Schema?

Answer: JSON Schema is a specification for JSON based format for defining the structure of JSON data.

42) What are the advantages of JOSN?

Answer:

  • It is used while writing JavaScript based applications that includes browser extensions and websites.
  • JSON format is used for serializing and transmitting structured data over network connection.
  • It is primarily used to transmit data between a server and web applications.
  • Web services and APIs use JSON format to provide public data.
  • It can be used with modern programming languages.

43) Can you write an example code in JSON?

Answer: The following example shows how to use JSON to store information related to books based on their topic and edition.

{

“book”: [

 

{

“id”:”01″,

“language”: “Java”,

“edition”: “third”,

“author”: “Herbert Schildt”

},

 

{

“id”:”07″,

“language”: “C++”,

“edition”: “second”

“author”: “E.Balagurusamy”

}

]

}

44) How JSON has been built?

Answer:

This is the basic JSON Interview Questions asked in an interview. JSON is built on two structures that are the collection of name/value pairs and ordered list of values. These are the universal data structures like object, array, string, number, and value.

45) What developers preferred to use JSON over XML?

Answer:

The advantages are as below:

JSON is faster and lighter than XML.

JSON has typed objects whereas in XML objects are typically less.

In JSON, there are different object types like integer, string, array etc. whereas in XML there is only one object type that is String only.

JSON data can be easily available or accessible as JSON object using in JavaScript but in XML data needs to be parsed and allocated to variables using APIs.

In JSON, retrieving the values is as simple as reading it from the property of the object from the javascript code.

46) Explain the features of JSON?

Answer:

JSON has a lot of features to use and advantages over the data interchange formats. It is easy to use and fast in nature. The lightweight of the JSON structure makes it quick to respond. It is mainly compatible with all the languages that are programming languages, browsers and platforms as well. It does not require any extra effort to ensure its compatibility with other platforms. It also supports a wide range of data types and data can be easily fetched.

47) Explain JSON-RPC and its features?

Answer:

JSON-RPC is referred to as a simple remote procedure call. It uses a lightweight JSON format. It is similar to XML-RPC but it is not using the XML format. It uses the java implementation JSON-RPC protocol. There are some features of the same like asynchronous communications, transparently maps Java Objects to javascript objects. It is a lightweight protocol. It calls dynamically server side java methods from JavaScript DHTML web applications. There is no page reloading happen for the same. It supports all browsers like internet explorer, Mozilla Firefox, safari, opera, and it uses the J2EE security model with session specific exporting of objects.

48) What are the limitations and uses of JSON?

Answer:

It has its own limitations:

It is not suitable for handling very large and complex data. When the data gets complex with several nested and hierarchical structures, it becomes complex for human readability. JSON does not support the comments. It does not support to handle the multimedia formats like image or rich text format.

There are many uses of JSON like it is mainly used for APIs and web service to transfer the data. It can be used in the combination with most of the modern programming languages. It can be used with javascript applications like websites or browser plugins. The most important use of JSON for transmitting the serialized data over a network connection between the systems. It can be used to read data from the webserver and display data in the web pages.

49) Explain Newtonsoft in JSON?

Answer:

Newtonsoft is referred to as the framework which is mainly used in the .net framework for performing the operations with JSON. It is also called as Json.net. There are a lot of features using Newtonsoft like it enables the user to parse, create, modify and query the JSON using its internal framework. It is simple and easy to use. It enables the user to serialize and de serialize any object with JSON serializer. It is faster than other serializers. It supports the conversion from XML to JSON and vice versa. Its syntax is simple and provides an easier way to query the JSON. It is a free and open source. To convert the data into JSON structure, a creation of an object is required to store data and once the object has been created then we can store the variables and keys in an object. After storing data in the object then we can serialize that data that is how serialization is done and de-serialization is reverse of it.

50) What is JSONP?

Answer:

JSONP is referred to as JSON padding. It can be defined as the process used by the javascript programs to call the data from the server that is available in the domain and it is different than the client. It is the method that is used to bypass the cross-domain policies in the web browser. It can be said in this way as to deal with browser restrictions when sending the JSON responses from the different domains of the client. It allows sharing the data with the same origin policy of system and environment.

51) Explain the syntax rules for JSON?

Answer:

This is the most popular JSON Interview Questions asked in an interview. In JSON, data is being arranged in Key value pair. In this left side represents the key and right side represents the value and these both things are separated by the colon. The data is mainly separated with help of using a comma. In JSON, curly braces define the objects and arrays are defined inside the JSON object by using the square brackets.

52) Explain the JSON files?

Answer:

The JSON file has an extension as ‘.json’ and MIME type for JSON text is “application/JSON”. JSON files can be edited or viewed with any text editor with notepad++ or notepad.

53)How to convert Javascript objects into JSON?

JSON.stringify(value); is used to convert Javascript objects into JSON.

Example Usage:

var obj={“website”:”Onlineinterviewquestions”};

JSON.stringify(obj); // ‘{“website”:”Onlineinterviewquestions”}’

54) List types Natively supported by JSON?

JSON supports Objects, Arrays, Primitives (strings, numbers, boolean values (true/false), null) data types.

55) What does Object.create do?

Object.create creates a new object with the specified prototype object and properties.

56)What does hasOwnProperty method do?

It returns true if the property was set on an actual object rather than inherited.

57) What does $.parseJSON() do ?

$.parseJSON() takes a well-formed JSON string and returns the resulting JavaScript value.

58)What are different ways to create objects?

You can create Object by

object literals

Object.create

constructors

59) What is the default value of a constructor’s prototype?

A plain, empty object that derives from Object.prototype is the default value of a constructor’s prototype

60) List some benefits of JSON over XML?

It is faster and lighter than XML as on the wire data format

XML data is typeless while JSON objects are typed

JSON types: Number, Array, Boolean, String

XML data are all string

Data is readily available as JSON object is in your JavaScript

Fetching values is as simple as reading from an object property in your JavaScript code

61) What is the difference between JSON and JSONP?

JSON: JSON is a simple data format used for communication medium between different systems

JSONP: It is a methodology for using that format with cross-domain ajax requests while not being affected by same origin policy issue.

62) Who is the Father of JSON and What is the scripting language JSON is based on?

Douglas Crockford called as the Father of JSON. JSON is based on ECMAScript.

63) What is JSON-RPC? List some Features of JSON-RPC-Java

JSON-RPC: JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML.

JSON-RPC-Java is a Java implementation of the JSON-RPC protocol.Below is list of some of its features

  • Dynamically call server-side Java methods from JavaScript DHTML web applications. No Page reloading.
  • Asynchronous communications.
  • Transparently maps Java objects to JavaScript objects.
  • Lightweight protocol similar to XML-RPC although much faster.
  • Leverages J2EE security model with session specific exporting of objects.
  • Supports Internet Explorer, Mozilla, Firefox, Safari, Opera, and Konqueror.

64) What are natively supported JSON types?

Following data types are natively supported in JSON.

Numbers: Integer, float or Double

String: string of Unicode characters, must be rapped into double quotes “”

Boolean: True or false

Array: ordered list of 0 or more values

Objects: An unordered collection key/ value pairs

Null: An Empty value

65) What is BSON?

BSON is the superset of JSON, which used by MongoDB.BSON supports the embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow the representation of data types that are not part of the JSON spec.

66) How to convert an Object into JSON? What is the full syntax of JSON.stringify?

JSON.stringify method is used to convert an Javascript Object into JSON.

Syntax:

let json = JSON.stringify(value[, replacer, space])

67) What JS-specific properties are skipped by JSON.stringify method?

Following JS-specific properties are skipped by JSON.stringify method

Function properties (methods).

Symbolic properties.

Properties that store undefined.

68) How do you decode a JSON string?

Use JSON.parse method to decode a JSON string into a Javascript object.

69) How to delete an index from JSON Obj?

Deleting an Element from JSON Obj

var exjson = {‘key’:’value’};

delete exjson[‘key’];

70) Do JSON support all the platforms?

Answer:

JSON almost supports all the platforms and programming languages because of its text format and most of the technologies mainly work with data transmission between the systems that support JSON format. There are many languages like PHP, Java, javascript etc.

Related Posts:

For more Interview Questions And Answers click here

1 thought on “[TOP 100] JSON Interview Questions And Answers

  1. Pingback: Interview Questions And Answers - CloudNClear

Comments are closed.