Activity Forums Salesforce® Discussions What is the difference between JSON and JSONP in Salesforce?

  • Avnish Yadav

    Member
    August 2, 2018 at 1:42 pm

    Hi Suniti,

    JSON: JSON is a simple data format used for communication medium between different systems
    JSONP: It is a methodology for using that format with cross-domain ajax requests while not being affected by the same origin policy issue.

    Thanks.

  • Parul

    Member
    September 15, 2018 at 5:08 am

    JSONP is a simple way to overcome browser restrictions when sending JSON  responses from different domains from the client. But the practical implementation of the approach involves subtle differences that are often not explained clearly. Here is a simple tutorial that shows JSON and JSONP side by side.

    JSON
    {"name":"stackoverflow","id":5}

    JSONP
    func({"name":"stackoverflow","id":5});

     

    Thanks

  • shariq

    Member
    September 16, 2018 at 9:50 am

    Hi,

    To make it more simple -

    JSONP is JSON with padding, that is, you put a string at the beginning and a pair of parenthesis around it. For example:

    //JSON
    {"helps":"old","age":55}
    //JSONP
    onOff({"helps":"new","age":65});

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos