Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Converters are pieces of javascript code that take the result from a query (and optionally metadata), process it into a custom array of objects and then pass it on to the template. Of course you can do some arbitrary calculations, formattings and renamings there as well. Most of the time converters are needed too. Converters are required mostly when dealing with JSON responses from REST APIs, but they can be applied to SQL results as well.


For various examples on how to use converters, refer to our List Of REST Examples.

Note: since version 3.7.0 converters may receive a second object as argument that contains the following query:

  • queryName (String)the name of the query currently executing this converter
  • queryParameters (Object): the parameters of the query currently executing this converter
  • originalQueryParameters (Object): same as queryParameter but before any processing took place (e.g. wildcard replacements)

Also see the last example below for more information how to use the second argument.

Example Converters

Converter scaffold:


Code Block
function convert(json) {
    var result = [];
    var parsedJsonObject = JSON.parse(json);
    var current, index;
    for (index in parsedJsonObject) {
        if (parsedJsonObject.hasOwnProperty(index)) {
            current = parsedJsonObject[index];
                'Page name':,
                'Date of pressing Like': PocketQuery.formatDate(current.created_time,'YYYY-MM-DD (dddd), hh:mm') + ' Uhr'
    return result;

Example converter using metadata (available since version 3.7.0):

Code Block
function convert(json, metadata) {
	return [{
		"QueryName": metadata.queryName,
		"QueryParameter Continent": metadata.queryParameters.Continent,
		"QueryParameter MinPopulation": metadata.queryParameters.MinPopulation,
		"Original QueryParameter Continent": metadata.originalQueryParameters.Continent,
		"Original QueryParameter MinPopulation": metadata.originalQueryParameters.MinPopulation