What is the difference between JSON and JSONP?

devquora
devquora

Posted On: Feb 22, 2018

 

    1 Answer Written

  •  devquora
    Answered by Satyam

    Difference between JSON and JSONP

    JSON stands for JavaScript object notation while JSONP stands for JavaScript object notation with padding. The former one refers to a standard format that is human readable and used to transfer the information from one server to another. Later one is a JSON having the ability to translate the entire information to other domains.

    Example of JSON is: {"Name": "Foo", "Id": 1234, "Rank": 7};

    Example of Jsonp is: functionCall({"Name": "Foo", "Id.": 1234, "Rank": 7});

    Understanding with JSON

    JavaScript object notation or JSON represents a lightweight data-interchange utility of format which is based upon the JavaScript literal representations for object, strings, numbers, booleans or array. Its variation is highly supported by several languages competing with XML as a dynamic protocol for web services and system configurations. It was formalized by Douglas Crockford in the year 2001. It may look like a JavaScript but it also follows certain specifications like-

    • Its strings are wrapped by double quotes
    • The number cannot have a dominant zero.
    • The concept of the JavaScript identifier is not suitable for JSON, where all the key names must be in the same string.

    Understanding with JSONP

    The data transfer between client and server is done by JSONP. When dealing with the data fetching, from different domains, Jsonp is utilized. Javascript object notation with padding or JSONP was documented for the first time by Bob Ippolito in the year 2005 as a simple and effective option to make the ability of script tags usable. In order to make the script tag work, it supports padding.

    Further differences are Between JSON and JSONP

    JSONJSONP
    The user cannot send a request to a different domainThe user can easily send a request to other domains as JSONP does not have difficulty with XMLHTTP request
    It supports the same domain origin requestsIt supports the cross-domain requests
    JSON is a generalized techniqueJSONP is actually Json along with padding
    When the destination is in JavaScript the transport of data is difficultThe data transfer is convenient when the destination is in JavaScript
    It does not use the tag <script>It uses the tag <script>

Related Questions

Please Login or Register to leave a response.

Related Questions

JSON Interview Questions

What is JSON? For what is used for?

JSON (JavaScript Object Notation) is a data storage and communication format based on key-value pair of JavaScript obje..

JSON Interview Questions

How to convert Javascript objects into JSON?

JSON.stringify(value); is used to convert Javascript objects into JSON.Example Usage: var obj={"website":"Onlineint..

JSON Interview Questions

List types Natively supported by JSON?

JSON supports Objects, Arrays, Primitives (strings, numbers, boolean values (true/false), null) data types...