formatJSON

To create a JSON string of a valid JSON object

This function converts a JSON object to a string. This can be useful if you want to check the content of an incoming JSON object or if you want to modify it with other text functions.

Syntax

formatJSON(JSON)

Return

string

Examples

With this script inserted in a button, you can store the response of an API GET request in the field Text to check the response object. Without formatJSON() the result would not be very helpful.

More about API at Ninox.

Please remember to exchange the following API key with your personal API key.

let databaseURL := "https://api.ninoxdb.de/v1/teams/" + teamId() + "/databases/" + databaseId() + "/tables/" + tableId(this);
let myAPIKey := "Bearer abcd1234-0000-xxxx-zzzz-1a1aa1aaa1a111";
let response := http("GET", databaseURL, {
		Authorization: myAPIKey
	}, null);
'Text' := formatJSON(response)

Result: You'll get a JSON string with data of your current table:

{"result":{"id":"I","name":"Table1","fields":[{"id":"A","name":"Text","type":"string"},{"id":"B","name":"Number","type":"number"},{"id":"D","name":"Text 2","type":"string"}]}}

See also

parseJSON, which converts a JSON string to a JSON object.

text, which converts a value to a string and possibly reflects the format options.

Last updated