JSON Interview Questions And Answers – 2

51. What are the uses of JSON?
JSON is mainly used for data interchange between the two systems.
• JSON is prominently used for 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 of the 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.

52. Explain JSON syntax rules?
There are several rules that describe the structure of the JSON. These are:
• Data inside a JSON is arranged in key-value pair. 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 pair is separated from the other pair by using a comma “,”.
• Curly braces define the JSON objects. Left curly brace “{“ represents the start of the object and right curly brace “}” represents the end of an object.
• Arrays are defined inside a JSON object by using square brackets “[ ]”.

53. Can you write an example code in JSON?
The following example shows how to use JSON to store information related to books based on their topic and edition.

"book": [

"language": "Java",
"edition": "third",
"author": "Herbert Schildt"

"language": "C++",
"edition": "second"
"author": "E.Balagurusamy"

54. What are the advantages of JSON over XML?
JSON has emerged as one of the most popular data interchange methods. It has several advantages over the XML that has to help it to replace XML as a most popular data transfer format.
• JSON is lighter and faster than the XML.
• JSON has object types but XML doesn’t define objects as types. JSON has different object type for a 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.

55. What are the similarities between JSON and XML?
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 the human.
• Both are independent of programming language.
• Both JSON and XML supports nested or hierarchical structures.
• Both of these can be parsed easily through several programming.
• Both these structures have support for Unicode.

56. Explain the use of NewtonSoft framework Net?
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 the 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.

57. Can a comment be added inside a JSON file?
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.

58. Name some of the most widely used libraries in .net for JSON?
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.

59. 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"}'

60. List types Natively supported by JSON?
JSON supports Objects, Arrays, Primitives (strings, numbers, boolean values (true/false), null) data types.

61. What does Object.create do?
Object.create creates a new object with the specified prototype object and properties.

62. What does hasOwnProperty method do?
It returns true if the property was set on an actual object rather than inherited.

63. What does $.parseJSON() do ?
$.parseJSON() takes a well-formed JSON string and returns the resulting JavaScript value.

64. What are different ways to create objects?
You can create Object by
• object literals
• Object.create
• constructors

65. 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

66. 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

67. 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 representation of data types that are not part of the JSON spec.

68. 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.
let json = JSON.stringify(value[, replacer, space])

69. 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.

70. How do you decode a JSON string?
Use JSON.parse method to decode a JSON string into a Javascript object.

71. How to delete an index from JSON Obj?
Deleting an Element from JSON Obj

var exjson = {'key':'value'};
delete exjson['key'];
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

− five = 1

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter