February 2

0 comments

JSON JSONP and P/JSON – Whats the difference?

By NickLitten

February 2, 2012

JSON, jsonp

Lets start from a point where you know what JSON is right?

JSON

JavaScript Object Notation or JSON (/JAY-sən), is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types. It is a very common data format used for asynchronous browser/server communication, including as a replacement for XML in some AJAX-style systems.

Data types in JSON include string, number, boolean, array

Simple Json might look like this:

{"name": "Nick","surname": "Litten", "website": "www.nicklitten.com"}

JSONP (also called P/JSON)

JSONP (JSON with padding) is used to request data from a server residing in a different domain than the client. JSONP enables sharing of data bypassing same-origin policy.

JSONP means its JSON with padding around it, normally used to request data from a server in a different domain.

Simple JsonP might look like

functioncallExample({"name": "Nick","surname": "Litten", "website": "www.nicklitten.com"});
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>