Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
JSON.Colorize
Formats a JSON string with color.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JSON | 8.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
(old name: JSON.Colourise)
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
json | A JSON text. | {"key":"value"} | |
DarkMode | Available in MBS FileMaker Plugin 12.1 or newer. Whether to swap colors to use white for text color. Pass 1 for dark mode and 0 for light mode. Default is 0 for light mode. |
0 | Optional |
Result
Returns formatted text or error.
Description
Formats a JSON string with color.This colorizes an existing JSON text to show to user, but does not check syntax.
Keys get blue, text value purple, numbers and others orange and brackets black.
Text is returned only with colors. You can apply text font and font size with normal FileMaker functions.
Processing time is linear to length, so should be faster than custom functions.
Applying text styles takes time. You may consider to skip this if your JSON is e.g. bigger than a million characters to improve performance of your scripts.
Examples
Colorize a field:
Set Field [ Data::JSON ; MBS("JSON.Colorize"; Data::JSON) ]
Colorize in Auto-Enter calculation:
MBS("JSON.Colorize"; self)
// put this calculation into a field, so the field gets colorized whenever the field is changed and the record gets commited.
Colorize leaves escapes in place:
MBS("JSON.Colorize"; "[\"Test\",\"🍎\",\"Escaped \uD83C\uDF4E\"]")
Example result:
["Test","🍎","Escaped \uD83C\uDF4E"]
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
- DynaPDF.GetDocInfoAsJSON
- DynaPDF.GetFieldsAsJSON
- DynaPDF.GetFontsAsJSON
- Files.AudioTags
- JSON.CreateArrayRef
- JSON.CreateObjectRef
- JSON.Format
- SmartCard.SplitValues
- Text.HTMLtoJSON
- WebRequest.GetHeaders
Release notes
- Version 12.5
- Fixed JSON.Colorize to work better with color for keys in nested objects.
- Version 12.3
- You can now use english spelling JSON.Colourise and XML.Colourise if you prefer to call JSON.Colorize or XML.Colorize.
- Version 12.1
- Added darkMode parameter for XML.Colorize and JSON.Colorize function.
- Version 11.5
- Fixed a problem in JSON.Colorize function with coloring arrays.
- Version 8.2
- Added JSON.Colorize and JSON.ToHTML functions.
Example Databases
- CURL/Email/IMAP Email
- CURL/FTP/CURL FTP Directory Listing
- Files/Audio File Tags
- JSON/JSON to HTML
- Mac and iOS/MapKit/Validate Address
- Network/Bonjour
- SmartCard/SmartCard ReadFile
- Win Only/Windows Location
- Win Only/WindowsML
- XML/XML to JSON
Blog Entries
- Use MapKit to validate addresses
- MBS Plugin Advent calendar: 2 - Vision
- Watch MongoDB Database
- Query current found set with Execute FileMaker Data API as JSON
- MBS FileMaker Plugin 12.1 - More than 6700 Functions In One Plugin
- XML and JSON Colorize for Dark Mode
- FileMaker Developers in Southern California
- With JSON in excellent form
- MBS FileMaker Plugin 8.3 released
- Colorize JSON or XML in FileMaker with line numbers
FileMaker Magazin
This function is free to use.
Created 6th April 2018, last changed 13th September 2024