Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

1) Mention what is JSON?

JSON is a simple data exchange format. JSON means JavaScript Object Notation; it is language and platform
independent.

2) Explain what is JSON objects?

An object can be defined as an unordered set of name/value pairs. An object in JSON starts with {left brace} and finish or
ends with {right brace}. Every name is followed by: (colon) and the name/value pairs are parted by, (comma).

3) Explain how to transform JSON text to a JavaScript object?

One of the common use of JSON is to collect JSON data from a web server as a file or HTTP request, and convert the
JSON data to a JavaScript, ant then it avails the data in a web page.

4) Mention what is the rule for JSON syntax rules? Give an example of JSON object?

JSON syntax is a set of the JavaScript object notation syntax.

 Data is in name/value pairs

 Data is separated by comma

 Curly brackets hold objects

 Square bracket holds arrays

5) Why must one use 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

6) Mention what is JSON-RPC and JSON Parser?

 JSON RPC: It is a simple remote procedure call protocol same as XML-RPC although it uses the lightweight
JSON format instead of XML
 JSON Parser: JSON parser is used to parse the JSON data into objects to use its value. It can be parsed by
javaScript, PHP and jQuery

7) Mention what is the file extension of JSON?

File extension of JSON is .json

8) Mention which function is used to convert a JSON text into an object?

To convert JSON text into an object “eval” function is used.

9) Mention what are the data types supported by JSON?

Data types supported by JSON includes

 Number

 String

 Boolean

 Array

 Object

 Null

10) Mention what is the role of JSON.stringify?

JSON.stringify() converts an object into a JSON text and saves that JSON text in a string.

11) Show how to parse JSON in JQuery?

To parse JSON in JQuery, we will see the example

var json = '{"name": "Guru 99", "Description ": "Learn PHP Interactively with PHP Beginner Tutorials"}'

obj = $.parseJSON(json);

//alert(obj.name);

12) Mention what is the function used for encoding JSON in PHP?

For encoding JSON in PHP, json_encode () function is used. This function returns the JSON representation of a value
on success or false on failure.
13) Explain how you can convert a string into a JSON Array?

To convert a string into a JSON array, you need to create a JSONObject object for each of your objects, and add those to
your JSON array.

14) Mention what are the JSON files?

 JSON file type for JSON files is “.json”

 The MIME type for JSON text is “application/json”

15) List out the uses of JSON?

Uses of JSON includes

 When writing application based on JavaScript it uses JSON, which includes browser extension and websites

 JSON is used for transmitting and serializing structured data over network connection

 JSON is mainly used to transfer data between server and web application

 Web service and API’s use JSON format to provide public data

 JSON can be used with modern programming language

16) Mention what are the drawbacks of JSON?

Drawbacks of json are

 It does not contain type definition

 It lacks some sort of DTD

17) Mention what is the MIME type of JSON?

MIME type for JSON text is “application/json”

18) Mention what is JSONP?

JSONP stands for JSON with padding. It is a method used to bypass the cross-domain policies in web browsers. In other
words, JSONP is the simple way to deal with browser restrictions when sending JSON responses from different domains
from the client.

19) Mention 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.

1. What exactly is JSON?

JSON is a faster and more accessible data exchange format. JSON (JavaScript Object Notation) is a platform and
language-independent data format. JSON is a wire protocol that specifies a data format for data exchange/communication
between processes/applications.

2. What exactly are JSON objects?

A collection of name/value pairs is referred to as an object. An object in JSON starts with a left brace and ends with a
right brace. A colon follows each name, and the name/value pairs are separated by a comma (comma).

3. How do you convert a JSON text to a JavaScript object?

JSON is widely used to collect JSON data from a web server in a file or an HTTP request, convert the JSON data to
JavaScript, and display the data on a web page.

4. Why is it necessary to utilise JSON instead of XML?

 JSON objects are typed JSON types: Number, Array, Boolean, and String are all sorts of data. It is faster and
lighter than XML since XML data is typeless over the wire.

 In XML, everything is a string.

 Data is readily available as a JSON object in your JavaScript.

 You have to read from an object property in your JavaScript code to get values.

5. Explain what JSON-RPC and JSON Parser are.

JSON RPC is a basic remote procedure call protocol similar to XML-RPC but uses the lightweight JSON format instead
of XML. JSON Parser is a tool for parsing JSON data. JavaScript, PHP, and jQuery can parse it. Mentioning the JSON
file extension JSON is a type of data format.

6. Which function is used to turn a JSON string into an object?

The "eval" function turns JSON text into an object.

7. What are the data types supported by JSON?

JSON supports a variety of data formats.

 Number

 String

 Boolean

 Array

 Object

 Null
8. What is the function of JSON.stringify?

JSON.stringify() converts an object to JSON text and saves the result as a string.

9. Mention the PHP function that is used to encode JSON.

To encode JSON in PHP, use the json_encode () function. This function returns a value's JSON representation; if it fails, it
returns false.

10. What steps are involved in converting a string to a JSON Array?

First, use the JSON. Parse() method to convert the JSON text to a JavaScript object, and then use the push() method to
extract the object's values and push them into the array.

11. What exactly are JSON files?

JSON files have the ".json" file extension. "application/json" is the MIME type for JSON text.

12. What are some of the applications of JSON?

JSON is used in multiple ways:

 JSON is used when creating JavaScript applications, such as browser extensions and websites.

 JSON is a serialisation and transmission standard for structured data across a network connection.

 Web services and APIs use the JSON format to deliver public data.

13. What are the disadvantages of JSON?

 JSON has several drawbacks.

 There is no type of definition in it.

 It's missing a DTD

14. Can you tell me what JSON's MIME type is?

"application/json" is the MIME type for JSON text.

15. Explain what JSONP is.?

JSONP is an abbreviation for JSON with padding. It's a technique for getting around cross-domain rules in web browsers.
In other words, when transmitting JSON replies from multiple domains from the client, JSONP is a straightforward
approach to cope with browser constraints.

16. Explain the distinction between JSON and JSONP.

JSON: JSON is a basic data format for exchanging information across systems.
JSONP is a way of using the JSON format with cross-domain ajax calls while avoiding the same-origin policy issue.

17. Do all programming languages and platforms support JSON?

Yes, JSON is supported by most technologies that work with data transmission between systems. JSON is supported by
practically all computer languages and platforms due to its text-based nature. Javascript, C, C++, C#, Perl, Java, Python,
PHP, and other languages are among them.
18. What exactly are JSON objects?

A set of key-value pairs is what defines an object. A left brace "precedes a JSON string and is followed by another right
brace ". A colon ":" follows each key, and a comma separates the key-value pairs ". A JSON object is a collection of keys
and their values organised in a pre-defined JSON structure.

19. What is the JSON file's extension?

The extension for a JSON file is ".json." A JSON file can be viewed or changed with any text editor, such as notepad or
notepad++ because it is text-based.

20. Describe the benefits and characteristics of JSON in detail.

The JSON structure has several benefits over other data transfer formats. They are as follows:

 The nature of the product is simple to use and quick. Data parsing is simple with the JSON syntax, and
implementation is faster. JSON's lightweight structure allows it to respond significantly more quickly.

 Multiple operating systems and browsers are supported. This allows the JSON format to be adapted to various
systems without requiring additional effort to ensure platform compatibility.

 Integers, doubles, strings, Booleans, and more data types.

JSON Interview Questions - For Experienced

21. What are the applications of JSON?

JSON is used in multiple ways:

 JSON is used when creating JavaScript applications, such as browser extensions and websites.

 JSON is a serialisation and transmission standard for structured data across a network connection.

 The JSON format offers public data via web services and APIs.

22. What are the rules of JSON syntax?

Several rules describe the structure of JSON. These are the following:

 The data in a JSON file is organised into key-value pairs. The key is on the left, while the data on the right
represents value. The separation of the key and the value is denoted by a colon ":"

 A comma is used to separate each set of key-value pairs from the other pair.

 The JSON objects are defined using curly brackets. The left curly brace "denotes the beginning of an object”,
while the right curly brace "denotes the end of an object”.

 The square brackets "[]" define arrays within a JSON object.

23. What advantages does JSON have over XML?

JSON is a data communication format. It has several advantages over XML that should assist it in displacing XML as the
most widely used data transfer standard.

 XML is heavier and slower than JSON.


 Object types are defined in JSON. However, they are not defined in XML. Different object types exist in JSON
for different data types, such as string, integer, Boolean, array, etc. The string is the only data type that all XML
objects are classified as.

 JavaScript makes it simple to read JSON data as a JSON object. On the other hand, the XML data must be parsed
and assigned to variables utilising APIs. Getting information from a JSON file is as simple as reading an object in
JavaScript.

 JSON is more accessible and helpful than XML because of its lightweight text-based nature.

24. What do JSON and XML have in common?

JSON and XML have a lot of similarities. It's as follows:

 JSON and XML are both used when transferring data between systems.

 JSON and XML are both human-readable and have a simple structure.

 Both are language agnostic.

 JSON and XML support nested or hierarchical structures.

 Both of them are simple to parse using a variety of programming languages.

 Both these structures support Unicode.

25. What are the different browsers that support JSON?

JSON support is built into nearly every new browser version. JSON is supported by many browsers, including Internet
Explorer, Chrome, Safari, and Mozilla Firefox.

26. What is the purpose of the NewtonSoft Net framework?

 Json.net, often known as Newtonsoft, is a popular.NET framework for executing JSON operations.

 It uses internal framework components like JArray, JValue, and JObject to allow users to parse, create, change,
and query JSON.

 It offers a more convenient way to query JSON using XPath-like syntax.

 Its excellent JSON serialiser allows users to serialise and de-serialise an object in .net.

 It outperforms current serialises in terms of speed.

 Simple and easy to use.

 It can also convert XML to JSON or the other way around.

27. Is there any possibility of adding a comment to a JSON file?

JSON does not accept comments because of its structure. However, comments can be stored in a Key or data object.
Ensure that your programme ignores the specified data element while processing the JSON.

28. What are some of the most extensively used JSON libraries in.NET?

In.net, there are several popular JSON libraries. Here are a few examples:
 Newtonsoft: It is one of the most extensively used c# conversion frameworks. It is well-known for its versatility
and performance. It also allows you to convert JSON to XML.

 DataContractJsonSerializer: This is Microsoft's built-in library for dealing with JSON objects in the.net
environment.

29. What are JSONP's limitations?

JSONP is used to get around web browsers' same-origin policies. It may be the ideal approach to get around the
restriction, but it comes with drawbacks. They are as follows:

 Because all JSONP calls must include a <script> element, the request can only be made via the GET method.

 POST and PUT requests are not supported.

 It can only be used for read-only APIs and services.

30. What is JSON Schema, and how does it work?

JSON Schema is a specification for specifying JSON data structure in a JSON-based format.

31. In JavaScript, what exactly is JSON?

Because JSON is derived from the JavaScript programming language, it makes sense to utilise it as a data format in
JavaScript. JavaScript Object Notation is abbreviated as JSON.

32. What are the benefits of using JSON?

 It's utilised in developing JavaScript-based applications, such as browser extensions and webpages.

 JSON is a serialisation and transmission standard for structured data over a network connection.

 It's mainly used to send data from a server to web apps.

 Web services and APIs use the JSON format to give public data.

 It's compatible with today's programming languages.

33. Why is JSON used in Android?

 It's a stand-alone data exchange format that's the most acceptable replacement for XML.

 To manipulate JSON data, Android supports four distinct classes.

34. What is the purpose of using JSON in Python?

JSON items are encoded and decoded using the Python programming language. The Python encode() function converts a
Python object into a JSON string. The decode() function converts a JSON string to a Python object.

35. Why is JSON used in PHP?

The JSON decode function transforms a JSON encoded string into a PHP variable. Built-in JSON methods are available
in PHP frameworks like Symfony and Laravel.

36. What is JSON Formatter, and how does it work?


The JSON Formatter & Validator aids in debugging JSON data by formatting and validating it so that it can be read easily
by humans.

37. What is a JSON Viewer?

JSON Viewer — Converts JSON Strings into an Easy-to-Read Format.

38. What is the purpose of a JSON Validator?

The JSON Validator aids in the debugging of JSON data by formatting and verifying it so that humans can read it.

39. What is the difference between Serialisation and Deserialisation in JSON?

JSON is a format for encoding objects that is based on strings. Serialisation transforms an object into a string, while
deserialisation converts a string back into an object. When data is transferred or stored in a file, it must be in byte strings,
although sophisticated objects are rare in this format.

40. What exactly is a JSON String?

A string comprising zero or more Unicode characters wrapped in double-quotes is paraded by backslashes. A single
character string represents a character. In C or Java, a string is similar to a string.

 A string (U+0022) is a collection of Unicode code points enclosed in 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, all code points may be inserted within quotation marks. Some characters have two-character escape
sequence representations.

 The quote mark character (U+0022) is represented by ", and the Reverse Solidus character (U+005C) is
represented by \.

 The Solidus character (U+002F) is represented by /.

 The Backspace character (U+0008) is represented by the letter b.

 The letter f represents the Form Feed character (U+000C).

 The Line Feed character (U+000A) is represented by n.

 The letter r represents the Carriage Return character (U+000D).

 The letter t represents the Tabulation character (U+0009).

Q #1) What is JSON? Explain.

Answer: JSON is the abbreviation of JavaScript Object Notation. It is one of the simplest data interchange formats,
independent of programming language and platform. Its lightweight text-based structure makes it easily readable. It is
derived from JavaScript for presenting simple data in the form of key-value pairs.

It is often used for serialization and transmission of data between network connections. It is mostly used for data
transmission between a web application and the server thereby making it a popular alternative to the XML format.

Q #2) Who is known as the father of JSON?


Answer: Douglas Crockford is known as the father of JSON. Douglas Crockford was the person who originally defined
the JSON format back in 2000.

Q #3) Do all the programming languages and platforms support JSON?

Answer: Yes, most of the technologies that work with the data transmission between the systems, support JSON format.
Due to its text-based nature, nearly all the programming languages and platforms can support JSON. These include
Javascript, C, C++, C#, Perl, Java, Python, Php, etc.

Q #4) What is meant by JSON objects?

Answer: An object is defined as a set of key-value pairs. A JSON starts with a left brace “{“ and ends with another right
brace “}”. Every key is followed by a colon “:” and the key-value pairs are separated from each other by using a comma
“,”. So, basically, the JSON object is a collection of keys along with their values arranged in a pre-specified JSON format.

Q #5) What is the extension of the JSON file?

Answer: A JSON file has an extension of “.json”. Being in a text-based format, a JSON file can be viewed or edited using
any text editor like notepad or notepad++.

Q #6) Explain in detail the advantages and features of JSON?

Answer: JSON structure possesses numerous advantages over the other data interchange formats. They are:

 Easy to use and fast in nature. JSON syntax offers easy parsing of data and even faster implementation. The
lightweight structure of JSON allows it to respond at a much faster rate.

 Compatible with numerous operating systems and browsers. This allows JSON schema to be attuned to many
platforms without any extra effort to make sure its compatible with another platform.

 Supports a wide range of data types including integers, double, String, Boolean, etc.

Q #7) What are the limitations of JSON?

Answer: JSON is one of the most popular data interchange formats available in today’s scenario. It has several
advantages over the other formats but at the same time, it also has its own set of limitations too. They are:

 As the data gets complex with several nested or hierarchical structures, it becomes complex for human readability.

 JSON is not suitable for handling very complex large data.

 JSON doesn’t have support for handling multimedia formats such as rich text or images.

 It doesn’t support comments.

Q #8) What are the uses of JSON?

Answer: JSON is mainly used for data interchange between the two systems.

 JSON is prominently used for the transmission of serialized data over a network connection between two systems.

 APIs and web services use JSON to format and transfer data.

 JSON can be used in combination with most modern programming languages.

 JSON can be used with JavaScript applications such as browser plugins and websites.
 JSON can be used to read data from the web server and display data on the web pages.

Q #9) Explain JSON syntax rules.

Answer: There are several rules that describe the structure of the JSON. These are:

 Data inside a JSON is arranged in key-value pairs. The left side represents the key and the data on the right side
represents value. Both key and value are separated by a colon “:”.

 Each set of key-value pairs is separated from the other pair by using a comma “,”.

 Curly braces define the JSON objects. The left curly brace “{“ represents the start of the object and the right curly
brace “}” represents the end of an object.

 Arrays are defined inside a JSON object by using square brackets “[ ]”.

Q #10) What are the advantages of JSON over XML?

Answer: JSON has emerged as one of the most popular data interchange methods. It has several advantages over XML
that has to help it to replace XML as the most popular data transfer format.

 JSON is lighter and faster than XML.

 JSON has object types but XML doesn’t define objects as types. JSON has different object types for different set
of data such as string, integer, Boolean, array, etc. All XML objects are categorized as just one data type, i.e.
string.

 JSON data can be easily accessed as a JSON object using JavaScript. On the other hand, the XML data need to be
parsed and allocated to the variables using APIs. Getting value out of a JSON is as easy as reading an object from
your JavaScript programming.

This text-based lightweight nature makes JSON more accessible and useful than XML.

Q #11) What are the similarities between JSON and XML?

Answer: There are several similarities that can be found between JSON and XML. They are:

 Both JSON and XML are used to transfer data between different systems.

 Both JSON and XML have a simple structure and are readable by humans.

 Both are independent of programming language.

 Both JSON and XML support nested or hierarchical structures.

 Both of these can be parsed easily through several programming.

 Both these structures have support for Unicode.

Q #12) Name the browsers that support JSON format.

Answer: Support for JSON is included in almost all the new versions of the browsers. Internet Explorer, Chrome, Safari,
Mozilla Firefox, etc. all support JSON format.

Q #13) Explain the use of NewtonSoft framework Net.


Answer: Json.net or Newtonsoft is one of the most popular frameworks used in .net for performing operations with
JSON.

 It enables the users to parse, create, modify and query JSON using its internal framework objects such as JArray,
JValue, JObject, etc.

 It provides an easier solution for querying JSON with a syntax similar to XPath.

 It enables the user to serialize or de-serialize any objects in .net with its great JSON serializer.

 It is faster than contemporary serializers.

 Easy to use and simple.

 It also supports conversion from XML to JSON or vice versa.

 One of the most important features is its free and open-source nature.

Q #14) How to use Newtonsoft or JSON.net for serializing JSON data?

Answer: Newtonsoft or JSON.net is one of the most widely used frameworks for serializing and deserializing JSON
structures in a .net environment.

To start converting the data into a JSON structure, we need to create an object to store the data.

Car car = new car();

Once we have created a new object we can define/store the keys and variables in that object.

car.Brand = "Hyundai";

car.Name = “Verna”;

car.Color = “Red”;

Once all the data are stored in the defined object, then we can serialize it using SerializeObject.

string json = JsonConvert.SerializeObject(car);

The JSON structure will be stored in the string defined. The structure will be something like this:

"Brand":"Hyundai",

"Name": "Verna",

"Color": “Red”

Q #15) How to use Newtonsoft or JSON.net for deserializing the JSON data?

Answer: Newtonsoft also provides functionality for deserializing the JSON structure to retrieve the data. The
deserialization process is just like the reverse of serialization. Here, the same steps are followed but in reverse order.

At first, we need to store the JSON that we want to deserialize in a string.


string JSON = @"{

"Brand": "Hyundai",

"Name": "Verna",

"Color": “Red”

Once we have stored the JSON structure in a string, we will use the following command to deserialize it and receive
different data.

Car m = JsonConvert.DeserializeObject<Car>(JSON);

Now, we will retrieve all the data from the JSON list one by one.

string Brand = m.Brand;

string Name = m.Name;

string Color = m.Color;

Q #16) Can a comment be added inside a JSON file?

Answer: As per the structure, JSON doesn’t support any comments. Although, a Key or data object can be used to hold
your comments. We need to just make sure that during the processing of the JSON, your application ignores the given
data element.

Q #17) Name some of the most widely used libraries in .net for JSON.

Answer: There are several popular libraries available for JSON in .net. Some of them are:

 Newtonsoft: It is one of the most widely used frameworks to convert using c#. It is quite famous because of its
flexibility and performance. It also supports JSON to XML conversion.

 DataContractJsonSerializer: This is the built-in library provided by Microsoft for handling JSON objects within
the .net environment.

Q #18) What is the use of JSON.parse in JavaScript?

Answer: It is used to parse the data present inside the JSON into objects for using its values.

The syntax used to parse JSON data:

string json = ‘{

"Brand": "Hyundai",

"Name": "Verna",

"Color": “Red”

}’

var obj = JSON.parse(json);


This will convert JSON data into the object from which we can retrieve the data for use with the application.

Q #19) Explain JSONP in a simple language.

Answer: JSONP is also known as JSON with Padding. It is a communication technique used by JavaScript programs to
call data from a server that is present in a domain, which is different than that of the client. JSONP allows the users to
share data without the restriction of the cross-domain or same-origin policy of the system and the environment.

Q #20) What are the limitations of JSONP?

Answer: JSONP is used to bypass the same-origin policy of web browsers. It may seem like a perfect way to get around
the restriction but it has its own set of limitations as well. They are:

 As all the JSONP calls are made by including a <script> tag, the request made is confined only to the GET
method.

 It cannot be used for POST or PUT requests.

 It can be used only for read-only services and APIs.

You might also like