Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.2   11.3   11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5    Statistic    FMM    Blog  

JSON.Format

Returns pretty printed JSON for the given JSON text.

Component Version macOS Windows Linux Server iOS SDK
JSON 4.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.Format"; json )   More

Parameters

Parameter Description Example
json A JSON text or reference. "[1,2,3]"

Result

Returns JSON code.

Description

Returns pretty printed JSON for the given JSON text.

Examples

Format some object:

Set Variable [$json; Value:MBS( "JSON.Format"; "{\"Hello\": \"World\"}" )]
Show Custom Dialog [$json]

Parse some JSON, display it formatted and release:

Set Variable [$json; Value:MBS( "JSON.Parse"; "{\"Hello\": \"World\"}" )]
Show Custom Dialog [$json; MBS("JSON.Format"; $json)]
Set Variable [$r; Value:MBS( "JSON.Release"; $json)]

Format various JSON entries:

MBS( "JSON.Format";
"{
\"Hello\": \"World\",
\"num\": 123,
\"value\": 123.456,
\"object\": {\"Hello\": \"World\"},
\"empty\": null,
\"array\": [1,2,3]}")

Example result:
{
  "Hello":   "World",
  "num":   123,
  "value":   123.456,
  "object":   {
    "Hello":   "World"
  },
  "empty":   null,
  "array":   [1, 2, 3]
}

Colorize and format in Auto-Enter calculation:

Let ( [
jsonFormatted = MBS("JSON.Format"; Self);
jsonFormatFailed = MBS("IsError");
jsonText = If(jsonFormatFailed; Self; jsonFormatted);
result = MBS("JSON.Colorize"; jsonText)
]; result )

// put this calculation into a field, so the field gets formated and colorized whenever the field is changed and the record gets commited.

See also

Release notes

  • Version 11.2
    • Fixed JSON.Format to not return reference number for JSON reference numbers as input, broken in 11.1.
  • Version 9.4
    • Improved pretty formatting for JSON arrays in JSON.Format.

Example Databases

Blog Entries

Created 18th October 2014, last changed 16th July 2022


JSON.FindValueInObjectArray - JSON.GetArrayItem

Feedback: Report problem or ask question.


Start Chat