Logo F2FInterview

JSON Interview Questions

Q   |   QA
‹‹ previous1234

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.

Douglas Crockford called as the Father of JSON

The JSON filename extension is .json.

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.
write your desire string in below format and use php funtions :
"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

Lighter and faster than XML as on-the-wire data format
JSON objects are typed while XML data is typeless
JSON types: string, number, array, boolean,
XML data are all string
Native data form for JavaScript code
Data is readily accessible as JSON objects in your JavaScript code whereas XML data needed to be parsed and assigned to variables through tedious DOM APIs
Retrieving values is as easy as reading from an object property in your JavaScript code

‹‹ previous1234

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: