Axiell WebAPI home page > Documentation > JSON output

JSON output

The JSON standard (JavaScript Object Notation) is an open, text-based data format, designed for human-readable data interchange. Despite its descendance from JavaScript - you need JavaScript to process it, XSLT can't be used - it is language-independent. JSON is more lightweight than XML (about half the data) and therefore faster to process. Another advantage is that JSON is allowed in cross domain AJAX requests.
More general information about JSON can be found here:

A number of WebAPI wwwopac.ashx commands have two optional JSON-specific arguments available: output and callback.

output

output determines the output format to be returned. Besides XML, the JSON output format can be returned by wwwopac.ashx. JSON output is smaller than XML, so it may improve performance of your WebAPI application. Values for output can be either json or xml (xml is the default, so you don't need to specify that explicitly).
Although JSON is not XML, output=json can be used together with the xmltype argument: if xmltype is set to grouped, the JSON output will be grouped, and for xmltype=unstructured the JSON output will be unstructured.
The output format produced by jQuery applications is always JSON, so you don't need to specify the output type there.
From WebAPI version 3.0.21040.1 a third JSON output format is available, which is more compact and easier to understand for developers who are used to writing JSON-based integrations: the main difference is the elimination of the "spans" arrays in favour of objects containing the grouped fields and there's also a change in the way enumerative values are presented. For an example, click here. The new format must be enabled in the adlibweb.xml configuration file and does not work with the xmltype parameter described above (but isn't hindered by it either), which means that existing JSON integrations do not need changing if the new format isn't required. To enable the new output format, you need to set the new <jsonFormat> element, with the value standard, in the <globalConfiguration> section of adlibweb.xml. For example:

<globalConfiguration>
   <databasePath>C:\Model-5.0\data</databasePath>
   <xmlType>grouped</xmlType>
   <jsonFormat>standard</jsonFormat>
</globalConfiguration>

After enabling this setting, when you make a call to the WebAPI with parameter output=json in the URL, you will get the improved JSON format in return. (With the setting enabled you can also still get the old format though, using output=jsonv1 as parameter, which produces the grouped XML type by default, but you can still use xmltype=unstructured if desired.) If the jsonFormat element is missing or has accidentally been set to anything other than standard, the regular JSON format will be output.

callback

callback returns JSON output wrapped in brackets with your callback function name, for AJAX requests: <callback function name>( <JSON output> ); You don't need to specify output=json, because the output format is JSON by default.

JSON output supported by OAI.ashx from version 3.0.21252.1

From WebAPI version 3.0.21252.1, oai.ashx produces JSON (implicitly of the more compact type) if the new setting: <output>json</output> has been configured in the <globalConfiguration> section in the adlibweb.xml configuration file. If you do not configure this option, the OAI result will be grouped XML. The output=xml or output=json query arguments (as supported for wwwopac.ashx) cannot be used for oai.ashx. This OAI functionality is not hindered or influenced by the XML type setting for wwwopac.ashx and vice versa the JSON format or XML type settings for wwwopac.ashx are not hindered by the JSON option for OAI, but if no <jsonFormat> has been specified for wwwopac.ashx then the <output>json</output> setting will cause wwwopac.ashx and oai.ashx (the latter from version 3.0.21273.1) to spit out JSON of the jsonv1 type unless (for wwwopac.ashx) the URL has an output=xml argument: a jsonFormat=standard argument won't work in that case.

At first, OAI jsonv1 type output was missing data about deleted records and resumption tokens, but this was fixed in 3.0.21277.1. For enumerative fields a difference remains between the pre-3.0.21277 version of jsonv1 and the new version of jsonv1: spans are missing for this field type, element “lang” is now “@lang” and element “text” is now “#text”: this will not be fixed.