Result Format

You can choose to receive service results in different formats according to your needs. The data structure will be consistent across the different formats as long as it is technically possible. For better readability, it is possible to request the data in pretty printed format. Please only use this possibility during the implementation phase of your application. Note that the amount of white space in the data and the line breaks may change without notice.

JSON, JSON-P and Javascript Output. These three output formats are basically the same format, they only differ in how the result is wrapped. JSON output has to be parsed by a JSON parser, while JSON-P and Javascript output can be directly included into a web page (using a <script> tag) and processed by the browser. To simplify matters, the remainder of this documentation will use the term JSON to refer to all three variants of this format.

JSON
{"version":1, …}
This result format is suited to be processed by an arbitrary JSON parser, which is offered for virtually every programming language/toolkit.
JSON-P
parseResponse({"version":1, …});

The browser will execute the specified callback function, as soon as the data has been received. This method is suitable to work around the same origin policy found in modern browsers, which prevents access to services originating from a different URL. Note that you have to ensure that the specified callback function exists before the result is received, otherwise a Javascript error will occur.

It is supported by popular Javascript toolkits like dojo (see the jsonp parameter for dojo.io.script.get), ext.js (Ext.data.ScriptTagProxy), jQuery (see the callback parameter for jQuery.getJSON) or MooTools More (Request.JSONP).

Javascript
var o={"version":1, …};
The result will be assigned to the specified Javascript variable. Note that the loading operation might be delayed and this variable will not be defined immediately after the including page was loaded.

XML Output.  All response data is wrapped in a root element called data. The version property is an attribute to this element.

<?xml version="1.0" encoding="ISO-8859-1"?>
<data version="1">
    ...
</data>

Plain Text Output.  Plain text responses will be very different across different services. In case of an error, it will only return the word Error followed by a colon and the actual error message. Warning and information messages will not be shown.

Error: Missing request parameters.
prev top | next >
Terms & Conditions Copyright © Time and Date AS
All data supplied by timeanddate.com