JSON (JavaScript Object Notation) is an open standard file format and data interchange format that stores and transmits data objects made up of attribute–value pairs and arrays using human-readable text (or other serializable values). It’s a common data format with a wide range of data transfer capabilities, including communication between web apps and servers.
Following are the frequent questions asked during JSON interview
Q1. What is the full form of JSON?
Ans: JSON stands for JavaScript Object Notation.
Q2. What exactly is JSON?
Ans. JSON is a straightforward data interchange format. JSON stands for JavaScript Object Notation, and it is platform and language independent.
Q3. What exactly are JSON objects?
Ans. An object is a collection of name/value pairs that are not in any particular order. In JSON, an object begins with a left brace and finishes with a right brace. (colon) follows each name, and the name/value pairs are separated by (comma).
Q4. How do you convert JSON text to a JavaScript object?
Ans. JSON is frequently used to collect JSON data from a web server as a file or HTTP request, transform the JSON data to JavaScript, and then display the data in a web page.
Q5. What are the syntax rules for JSON? What is a good example of a JSON object?
Ans. A collection of JavaScript object notation syntax is known as JSON syntax.
- The information is organized into name/value pairs.
- A comma separates the data.
- Objects are held in place using curly brackets.
- Arrays are held in square brackets.
Q6. Why is it necessary to utilize JSON instead of XML?
Ans. following are the reason to use JSON instead of XML
- As an on-the-wire data format, it is faster and lighter than XML.
- JSON objects are typed, but XML data is type less.
- Number, Array, Boolean, and String are all JSON types.
- All of the data in XML is a string.
- As a JSON object in your JavaScript, data is readily available.
- Reading from an object property in your JavaScript code is all it takes to get values.
Q7. Explain what JSON-RPC and JSON Parser.
Ans. JSON RPC is a basic remote procedure call protocol similar to XML-RPC, but instead of XML, it uses the lightweight JSON format.
A JSON parser converts JSON data into objects that may be used. JavaScript, PHP, and jQuery can all parse it.
Q8. Mention what the JSON file extension is.
Ans. JSON’s file extension is .json
Q9. Mention the function that converts a JSON string to an object.
Ans. The “eval” method is used to turn JSON text into an object.
Q10. What are the data types that JSON supports?
Ans. JSON supports a variety of data formats.
- Number
- String
- Boolean
- Array
- Object
- Null
Q11. What is the function of JSON.stringify?
Ans. JSON.stringify() takes an object and turns it to JSON text, which is then saved as a string.
Q12. What is the best way to parse JSON in JQuery?
Ans. We’ll look at an example of parsing JSON in JQuery.
var json = '{"name": "Orapoint", "Description ": "Learn JSON"}' obj = $.parseJSON(json); //alert(obj.name);
Q13. What function is used to encode JSON in PHP?
Ans. The json encode () function is used to encode JSON in PHP. On success, this method returns the JSON representation of a value; on failure, it returns false.
Q14. What is the process for converting a string to a JSON Array?
Ans. Create a JSONObject object for each of your objects and add it to your JSON array to convert a string to a JSON array.
Q15. What exactly are JSON files?
Ans. The “.json” file extension is used for JSON files.
“application/json” is the MIME type for JSON text.
Q16. What are some of the uses of JSON?
Ans. JSON is used in a variety of ways.
- When building JavaScript applications, JSON is used, which includes browser extensions and websites.
- JSON is a format for serializing and sending structured data over a network.
- JSON is mostly used to send data from a server to a web application.
- To give public data, web services and APIs use the JSON format.
- JSON is a modern programming language that can be used.
Q17. What are the disadvantages of JSON?
Ans. Json has a number of drawbacks.
There is no type definition in it.
It is missing a DTD of some sort.
Q18. What is the JSON MIME type?
Ans. “application/json” is the MIME type for JSON text.
Q19. What exactly is JSONP?
Ans. 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.
Q20. What is the difference between JSON and JSONP?
Ans: JSON is a basic data format for exchanging information across systems.
JSONP is a way for using the JSON format with cross-domain ajax calls while avoiding the issue of the same origin policy.