JSON Interview Questions and Answers
Freshers / Beginner level questions & answers
Ques 1. Who is the Father of JSON ?
Douglas Crockford is the Creator or Father of JSON.
Ques 2. What is JSON?
JSON full form is JavaScript Object Notation. JSON is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. And JSON is language-independent, with parsers available for virtually every programming language. Uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python,php
The JSON format is often used for serializing and transmitting structured data over a network connection. When third party data interchane(REST Services) then JSON may used there LIKE SHOP .It is primarily used to transmit data between a server and web application, serving as an alternative to XML.
Ques 3. What is the file extension of JSON?
The JSON filename extension is .json.
Ques 4. Explain JSON with php.
Json is too much easy with php There is no installation needed to use these functions; they are part of the PHP core. nothing more need to know just only use { ,[ and create json format string and use three php function json_encode() to get JSON representation of a value, json_decode() for Decodes a JSON string, ¦json_last_error() to get the last error occurred in process.
Example:
$string='{
"firstName": "Rohit",
"lastName": "Singh",
"age": 26,
"address": {
"streetAddress": "Mira Road Thane ",
"city": "Mumbai",
"state": "maharshtra",
"postalCode": "401107"
},
"phoneNumber": [
{ "type": "home", "number": "022 333-1234" },
{ "type": "fax", "number": "022 444-4567" }
]
}';
$decodeString = json_decode($string);
echo 'First Name - '.$decode->{"firstName"};
echo 'Last Name - '.$decode->{"lastName"};
echo 'Address - '.$decode->{"address"}->{"streetAddress"};
Out put : Print below
First Name - Rohit
Last Name - Singh
Address - Mira Road Thane
Ques 5. What are the JSON Tools for Java Developer?
Some of JSON tools for java developer is
• Parser
> Parse JSON text files and convert these to a Java model
• Renderer
> Render a Java representation into text
• Serializer
> Serialize plain POJO clusters to a JSON representation
• Validator
> Validate the contents of a JSON file using a JSON schema
JSONObject Java Class
• A JSONObject is an unordered collection of name/value pairs
• The put methods adds a name/value pair to an object
• The texts produced by the toString methods strictly conform to the JSON syntax rules
myString = new JSONObject().put("JSON", "Hello, World!").toString();
// myString is {"JSON": "Hello, World"}
Most helpful rated by users:
- Who is the Father of JSON ?
- What is the file extension of JSON?
- What is JSON?
- Why use JSON over XML?
- Explain JSON with php.