![]() |
JSON or JavaScript Object Notation is a format that is independent of any language and used for data transmission between the server and the web app. It is a lightweight data-interchange format that mainly uses JavaScript syntax but always formats in text format only. JSON Interview Questions1. What is JSON?JSON stands for JavaScript Object Notation but it does not use JavaScript to perform operations, it just uses the JavaScript syntax. It is a light-weighted and language-independent format mainly used to transmit the data between the server and the web app. 2. Explain the structure and format of JSON.The JSON format follows the structure of the JavaScript object. It contains the key-value pairs in the form of strings that can be transmitted from server to web app and vice-versa. The values stored in JSON can be retrieved in the same way as the values of JavaScript object are retrieved. { 3. Who created JSON?Douglas Crockford was the first man who introduced and created the JSON format first in 2000. 4. What is the extension for the JSON files?The JSON files can be created and stored using the .json extension. You can add the data in the form of JSON format using the key-value pairs in the form of strings. 5. What is the reason for using JSON?JSON is a light weighted format that is used to transfer the data on the network. The main reason for using JSON is that it provides a very simple and easy way to communicate between the server and the web app by data transmission. It is used as an alternative for the XML format. 6. What are the features of JSON?There are different features of JSON as listed below:
7. List different data types supported by JSON.JSON has a support for the following data-types:
8. How to create a JSON array?A JSON array is just like the arrays in the other programming languages that contains a collection of multiple items of different data-types. It can contain value of any data-type supported by JSON. ["value1", 12, true, null]
9. Is it possible to create function in JSON?No, as we know JSON is just a data format and it is used to transfer data on the network. Therefore, we can not write any kind of executable code inside it. 10. How to retrieve the data stored in JSON object?You can retrieve or access the values stored in an JSON object in the same way as we access them in JavaScript. The below methods can be used to access the values of JSON object.
11. Explain the process of accessing JSON object values using dot notation.You can follow the below syntax to retrieve values of JSON object using dot notation. const JSONObj = { 12. Explain the process of accessing JSON object values using square brackets.You can follow the below syntax to retrieve values of JSON object using square brackets. const JSONObj = '{ 13. Explain JSONP and how it is different from JSON?JSONP stands for JSON with Padding. It is a method for sending the JSON data with padding to avoid cross domain restrictions. JSONP is different from JSON, because it allows the cross-origin requests. 14. List different browsers that support JSON.JSON is supported by all the modern browsers. As we know, JSON follows the JavaScript syntax, hence every browser has built-in support for it. The below browsers support JSON:
15. Explain the use of JSON.parse() method in JSON.The JSON.parse() method is used to parse the JSON data into JavaScript and converts the JSON string into a JavaScript object. JSON.parse(JSONString, function)
16. What is the JSON.stringify() method used for?The JSON.stringify() method is used to convert the JavaScript object into a JSON string format. JSON.stringify(JSONString, function, space)
17. Explain JSON schema.JSON schema is a content specification language defined to validate the structure and the format of JSON data or string. It defines the basic structure, format and important constraints of JSON data. 18. How to write JSON in an HTML document?You can write or include the JSON data inside and HTML document using a <script> tag with type attribute by passing a value as application/json to it. <script type="application/json"> 19. What are the methods used to encode and decode JSON in PHP?We can use the below methods to encode and decode JSON in PHP:
20. What is the MIME type for JSON?The MIME type for JSON is application/json. You can pass this type as an value to the type attribute inside the script tag to include JSON into your HTML document. 21. What are the benefits of using JSON?The below list contains some benefits of using JSON:
22. Explain disadvantages of using JSON.There are some disadvantages of using JSON:
23. What are the applications of JSON?JSON can be used in different situations:
24. List some of the popular libraries for working with JSON in JavaScript.Below are some of the popular libraries for working with JSON in JavaScript:
25. Differentiate between JSON and XML.JSON and XML are the formats used to transfer data over the network. But there are some differences between them as listed in the below table:
26. What are the similarities between JSON and XML?There are some similarities between JSON and XML as listed below:
27. What is Serialization and Deserialization in JSON?
28. How to handle JSON parsing errors in JavaScript?The JSON parsing errors can be handled using the try/catch block with the parsing statements in JavaScript. 29. Is it possible to create duplicate keys in an JSON object?No, JSON does not allow to create duplicate keys in an object. If there’s a duplicate key created in some scenario, then the last occurrence of that key will replace the previous occurrence. 30. Explain JSON web token and its implementation.JSON web token or JWT is a self-contained and compact way to transmit the data securely between server and web app in JSON object format. It consist of three parts as the header, the payload, and the signature. All the parts of JWT are encode in base64 format which are concatenated to form a JWT. 31. How to transmit JSON data securely over the internet?The JSON data can be securely transmitted over the internet using the HTTPS (Hyper Text Transfer Protocol Secure) protocol. It encrypts the data during its transmission over the internet. 32. What is JSON-LD and how it is different from JSON?JSON-LD stands for JSON for Linking Data. It is a lightweight Linked Data format that is designed to integrate with the JSON based APIs that are already existing on he internet. It is different from regular JSON as it involves the additional context and semantics for the better data interoperability. 33. What is the purpose of toJSON() method in JSON?The toJSON() method in JSON is used to convert the date returned by the Date constructor in the string format. dateObj.toJSON();
34. What are JSON formatter and Validator?The JSON formatter and Validators are the tools used to format and validate the JSON data. These tools convert the JSON data into a human-readable format by ensuring its readability, correctness, and adherence to JSON syntax. 35. What are the alternatives of JSON?There are some alternatives available for JSON as listed below:
|
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |