JSON Interview Questions

8 0 0
                                        


JSON interview questions and answers

1. What is JSON? For what is used for?

JSON (JavaScript Object Notation) is a data storage and communication format based on key-value pair of JavaScript object literals. It is a lightweight text-based open standard designed for human-readable data interchange which is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects.

In JSON

all property names are surrounded by double quotes.values are restricted to simple data: no function calls, variables, comments, or computations.

JSON is used for communication between javascript and serverside technologies.

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

3. List types Natively supported by JSON?

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

4. What does Object.create do?

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

5. What does hasOwnProperty method do?

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

6. What does $.parseJSON() do ?

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

7. What are different ways to create objects?

You can create Object by

object literalsObject.createconstructors

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

9. List some benefits of JSON over XML?

It is faster and lighter than XML as on the wire data formatXML data is typeless while JSON objects are typedJSON types: Number, Array, Boolean, StringXML data are all stringData is readily available as JSON object is in your JavaScriptFetching values is as simple as reading from an object property in your JavaScript code

10. What is the difference between JSON and JSONP?

JSON: JSON is a simple data format used for communication medium between different systemsJSONP: It is a methodology for using that format with cross-domain ajax requests while not being affected by same origin policy issue.

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

You've reached the end of published parts.

⏰ Last updated: Mar 03, 2018 ⏰

Add this story to your Library to get notified about new parts!

JSON Interview QuestionsWhere stories live. Discover now