Json object support, Reading json objects, Writing json objects – NetMedia iViewHD-2M User Manual

Page 41: Jsonp support, Iviewhd userʼs manual

Advertising
background image

JSON Object Support

The iViewHD camera supports a variety of JSON (JavaScript Object Notation) objects to manipulate
camera parameters. JSON is of primary interest to those that want to make custom web applications
that communicate to the iViewHD camera without having to issue HTTP commands. For a general
outline on what JSON is and various JSON links, please see

http://www.json.org

/

iViewHD supports both reading and writing JSON objects. JSON objects are read/written using GET
or PUT JavaScript XMLHttpRequest calls. Because JSON objects may contain special characters, it
is always best to URL encode the JSON request using something like JavaScriptʼs escape function.

Reading JSON Objects

To read a JSON object issue a GET or PUT request in the form

/JSON.cgi?GETSET=0&COMMAND=<JSON-Partial-Objects>

where

<JSON-Partial-Objects>

denotes JSON objects to be retrieved formatted as JSON objects

without their corresponding values. For example,

{“JSONVersion”:}
{“CameraParameters”:}
{“CameraStats”:}
{“”:}

The object name may also be an empty string, in which case all JSON objects will be retrieved.

Writing JSON Objects

To write a JSON object issue a GET or PUT request in the form

/JSON.cgi?GETSET=1&COMMAND=<JSON-Object>

where

<JSON-Objects>

denotes a single JSON object and its corresponding values. For example,

{“CameraParameters”:{"OutputSize":[1600,1200]}}

Some JSON parameters are Read-Only and attempting to change them has no effect. Other JSON
parameters are used internally and are not documented here.

JSONP Support

iViewHD also supports JSONP (JSON with Padding). This allows the JSON object to be returned sur-
rounded by parenthesis and an object name such as a function. If youʼre not familiar with JSONP,
here are some links

http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
http://ajaxian.com/archives/jsonp-json-with-padding

To use JSONP use the following syntax:

/JSON.cgi?GETSET=0&JSONP=<JSONP-Name>&COMMAND=<JSON-Partial-Objects>

where

<JSONP-Name>

is the JSONP prefix that will be returned with the response. The

JSONP=

desig-

nator needs to come before the

COMMAND=

designator. For example,

/JSON.cgi?GETSET=0&JSONP=showVersion&COMMAND={“JSONVersion”:}

would return something like

showVersion({“JSONVersion”:4096})

iViewHD Userʼs Manual

© 2009 NetMedia, Inc. 41

Advertising
This manual is related to the following products: