Iteanz Interview Questions | Latest Technologies Interview Questions

Json Interview Questions and Answers

Written by Bharathkumar | Sep 10, 2022 6:49:36 AM

1. What is the full form of JSON?
JSON stands for JavaScript Object Notation.

2. What is the definition of JSON?
It is a text-based format and designed for the exchange of data between two different systems. It is lightweight data-interchange format as compare to XML. It uses JavaScript syntax. JSON data can be read and use by any programming language.

3. What is JSON used for?
JSON is used for communication between server side technologies and mobile app or website.

4. What is the file extension of JSON?
The file extension of JSON is .json.

5.  Who created the JSON?
Douglas Crockford

6.  Who is Father of JSON?
Douglas Crockford

7. Why It is so popular?

  1. It is light weight standard for exchange information
  2. It is independent of language
  3. It is independent of Hosting Server
  4. Human Readable
  5. Easy to Encode
  6. Easy to Decode
  7. Used in Mobile application

8. What is file extension of JSON?
json

9. What is the rule for writing JSON?

  • JSON is the collection of key and value pair separated by the comma.
  • Key and value are separated by the colon (:).
  • Square brackets are used to store JSON array.
  • Curly brackets are used to hold JSON objects.

10. How many data types are there in JSON?

There are six types of data types in JSON –

  • Number
  • String
  • Boolean
  • Array
  • Object
  • Null
 11. JSON vs. XML?
  • XML requires XML parser to parse it. JSON is parsed with the help of JavaScript functions.
  • XML is heavy and verbose. JSON is short and lightweight.
  • File extension of XML data is .xml. File extension of JSON data is .json.
  • XML is document based. JSON is data based.
  • JSON is simple to read, write and understand. XML is less simple to read, write and understand.
  • Array is supported by JSON. Array is not supported by XML.
  • JSON stands for JavaScript Object Notation. XML stands for Extensible Markup Language.

12.  What is MIME type for JSON data?

MIME type is application/json.

13.  Which functions are used for encoding and decoding JSON in PHP?

For encoding, json_encode() function is used. This function takes PHP value like array as input and returns JSON representation of it. For decoding, json_decode() function is used. This function takes JSON string as input and returns associative array.

14. What is the use of JSON.stringify() function?

JSON.stringify() function is used to convert a JavaScript value(Object) into a JSON string.

15. What is MIME type for JSON data?

MIME type is application/json.

16.  Which functions are used for encoding and decoding JSON in PHP?

For encoding, json_encode() function is used. This function takes PHP value like array as input and returns JSON representation of it. For decoding, json_decode() function is used. This function takes JSON string as input and returns associative array.

17.  What is the use of JSON.stringify() function?

JSON.stringify() function is used to convert a JavaScript value(Object) into a JSON string.

18.  What is the purpose of JSON.parse() function?

This function is used to convert JSON string into a JavaScript object.

19.  What is JSON Parser?
JSON Parser is used to parse the JSON data into object to use its value. JSON can be parse by javaScript, jQuery and PHP.

20.What is JSON-RPC?

Remote Procedure call protocol with use of JSON. It is similar to XML-RPC only difference, It use JSON instead of XML.

21. What is JSON-RPC-Java?
JSON-RPC-Java is a Java implementation of the JSON-RPC protocol.

22. How to create json from php array?

$array = array('name'=>'PHP Tutorial','Description'=>'Web technology experts notes');
echo json_encode($array);

23.  How to get PHP array from json Object?
$object='{“name”:”PHP Tutorial”,”Description”:”Expert in web technology”}’; $array = json_decode($object);

24. How to parse JSON in JavaScript?

var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
var obj = JSON.parse(json);
//alert(obj.name);

25.  How to create JSON Object from JavaScript?
var obj = {}; obj[‘name’]=’php-tutorial-php.blogspot.in’; //string obj[‘age’] = 32; // integer. obj[‘marks’]= [80,70,60,50,60,80]; //array

26. How to parse JSON in jQuery?

var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
obj = $.parseJSON(json);
//alert(obj.name);

27.  How to Validate json in php?

$json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}';
$obj = json_decode($json);
if(is_null($obj)) {
die('Invalid JSON');
}

28.  How to Validate json in javascript?
function isValidJson(jsonData) { try { JSON.parse(jsonData); return true; } catch (e) { return false; } } var json = ‘{“name”:”PHP Tutorial”,”Description”:”Web technology experts notes”}’ isValidJson(json);

29.  How to Validate json in jQuery?
function isValidJson(jsonData) { try { $.parseJSON(jsonData); return true; } catch (e) { return false; } } var json = ‘{“name”:”PHP Tutorial”,”Description”:”Web technology experts notes”}’ isValidJson(json);

30.  How to get JSON response in Ajax?

$.ajax({
dataType: "json",
url: '/ajax/url',
data: 'name=php-tutorial-php',
success: function(data){
//data
}
});