Zoho - Trademark
Blogs
   Forums   Show Home
   Toll Free : 888 900 9646

API Home >> Show >> REST Response >> JSON


JSON


JSON (JavaScript Object Notation) is a lightweight data interchange format. It is a text-based format for representing objects and other data structures and it's easy to use with JavaScript.


To get the API response in JSON format, your API request should be of the form

 http://show.zoho.com/api/[private or public]/ json / ...

Wherever you find 'xml' in request URLs, just replacing it with "json" will produce the response in JSON format.

For example to get an info of a specific presentation in JSON format, the URL will be:

http://show.zoho.com/api/private/json/info/[presentationId]?apikey=[apikey]&ticket=[ticket]



JSON Response

The structure for JSON response is same as that of XML response.Thus, by looking at the XML response structure, one can figure out the JSON response structure.

Some simple conventions used for mapping the XML structure to JSON structure is explained here
Some sample XML and their corresponding JSON structures are listed below

A.


<response uri="/api/private/xml/info/15265000000006067" />




{
    "response" : {
        "uri" : "/api/private/json/info/15265000000006067"
    }

}



B.



<response uri="/api/private/xml/tags/15265000000006067">
<tag name=
"converter">
</response>




{
    "response": {
        "uri": "/api/private/json/tags/15265000000006067",
        "tag": {
            "name":
"converter"
        }
    }
}



C.


<tags>
<tag name=
"converter">
<tag name="RGB">
</tags>




{
    "tags":
    {
        "tag":
        [
            {
                "name": "converter"
            },
            {
                "name": "RGB"
            }
        ]
    }
}



Sample Response in JSON


Here's a sample JSON response to the API that lists info of a specific presentation.

XML Response:



<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/api/private/xml/info/3000000005001">
<result>
    <presentation>
      <presentationId>3000000005001</presentationId>
      <presentationName>ajax</presentationName>
      <ownerName>Mickie</ownerName>
      <createdTime>Tue 03/27/07</createdTime>
      <isPublic>false</isPublic>
      <lastModifiedTime>15 hours ago</lastModifiedTime>
      <slideTransitionTime>0</slideTransitionTime>
      <lockedBy />
      </presentation>
</result>
</response>


Equivalent JSON response


{
    "response":
    {
        "uri": "/api/private/json/info/3000000005001",
             "result":
      
  {
               "presentation":
                [
                   {
                      "
presentationId":"3000000005001",
                     
"presentationName":"ajax",
                     
"ownerName":"Mickie",
                     
"createdTime":"Tue 03/27/07",
                     
"isPublic":"false",
                     
"lastModifiedTime":"15 hours ago",
                                            "slideTransitionTime":"0",
                                            "lockedBy":""
                                     }
                               ]                     
          
        }
   
}
}




Sample Error Response in JSON


A sample response in JSON in case of exceptions during method call is listed below:


 
{
    "response":
    {
        "uri":"/api/private/json/info/15265000000006067",
        "error":
        {
            "code":3401,
            "message":"Specified ticket [90402229B3347AAA447] is no longer valid. Provide a correct one."
        }
    }
}



JSONP (JSON Callback) Support


By default, the JSON response cannot be used directly in client-side JavaScript, as XMLHttp does not support cross-domain requests due to security concerns. To get around this cross-domain problem, a simple trick called JSON callback(JSONP) can be used.

On giving a additional query parameter 'callback' to your JSON requests, the response object will be wrapped inside the given callback function name.

The request
http://sheet.zoho.com/api/private/json/tags/15265000000006067?apikey=[apikey]&ticket=[Ticket]&callback=listTags

will produce the JSON response wrapped in a function call 'listTags' .



listTags
(
    {
        "response":
        {
            "uri":"/api/public/json/tags/
15265000000006067",
            "result":
            {
                "tags":
                {
                    "tag":
                    [
                        {
                            "name":"weight"
                        },
                        {
                            "name":"tracker"
                        }
                    ]
                }
            }
        }
    }

)



Thus JSON response can be loaded using <script> tags on the client rather than using XMLHttp. Now, the JSON output will be loaded when the page is loaded. As the output is a valid function call, the function 'listTags' will be invoked. The JSON response object will be available as function argument.