When we executed our first REST Query, the result looked like this:

This is because the JSON that we get from our Datasource contains a lot of values and even some lists or nested objects:

[
  {
    "name": "Åland Islands",
    "topLevelDomain": [".ax"],
    "alpha2Code": "AX",
    "alpha3Code": "ALA",
    "callingCodes": ["358"],
    "capital": "Mariehamn",
    "altSpellings": ["AX", "Aaland", "Aland", "Ahvenanmaa"],
    "region": "Europe",
    "subregion": "Northern Europe",
    "population": 28875,
    "latlng": [60.116667, 19.9],
    "demonym": "Ålandish",
    "area": 1580.0,
    "gini": null,
    "timezones": ["UTC+02:00"],
    "borders": [],
    "nativeName": "Åland",
    "numericCode": "248",
    // ... more data
  },
  // ... more countries
]
CODE

Now, most of this data we actually don’t want to display in our table. There’s only a few fields out of these that we want. But how do we do this? Well, this is exactly what Converters are for. So, let’s go ahead and create one!

Converters are JavaScript functions that take in the raw result from your Datasource, operate on it, and return something else. The return value could for example be a sorted version of the data or a filtered version, just like in our case. Fill in the fields with these values:

Field

Value

Name

REST Countries Filter

Content

function convert(json) {
  return JSON.parse(json).map(country => {
	return {
	  'Flag': country.flag,
	  'Name': country.name,
	  'Code': country.alpha2Code,
	  'Capital': country.capital,
	  'Population': country.population
	}
  });
}
JS

To make our Query use our newly created Converter, we have to go to the Queries tab and edit our “Countries per regional bloc“ Query. In the Query form, click on the Converter select box and choose our “REST Countries Filter” Converter.

After you have updated your Query, go back to your Confluence page and execute it once more, to see what’s changed. Your table should now look like this:

Ah, much better! Our table now displays exactly the columns we want. But wouldn’t it be cool, if we could display actual flags instead of the link to a flag in the first column? Well… if you’ve read “The PocketQuery Entities“ you probably know what comes next.

Continue with “Customizing the appearance of your Query with a Template