Brian Dunning's FileMaker Custom Functions

@JsonFormatElements ( json )

Formats JSON data in two columns: elements hierarchy and values. Version 2.1

  Average rating: 3.0 (1 vote) Log in to vote

Alex Zueiv   Alex Zueiv - Show more from this author
Tashkent
https://github.com/zueiv

Share on Facebook Share on Twitter

  Sample input:
@JsonFormatElements ( "[{\"exclamation\":\"Hello\"},[{\"punctuation\":\" \"},[{\"noun\":\"World\"},[{\"punctuation\":\"!\"}]]]]" )
  Sample output:
[
    {
        "exclamation"               : "Hello"
    },
    [
        {
            "punctuation"           : " "
        },
        [
            {
                "noun"              : "World"
            },
            [
                {
                    "punctuation"   : "!"
                }
            ]
        ]
    ]
]

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This CF is intended for developers. It allows you to visually separate the data from the document structure. This makes working with JSON API more comfortable.

Required FM16+ (no runtimes).

v2.1 fix: Added 5000 ms time limit to prevent a hang on a large document.

 

Comments

Beverly Voth   Beverly Voth, beverlyvoth
May 17, 2023
I found a problem with this today. When copied & tried to add to FMP19.5.4, I got an error about "The selected name cannot be used because it..."
Likely the same name as a current function, it won't let me create even with the "@" prepended
FIX: change the name to `@JsonFormatFixElements` (everywhere as this is recursive function).
 
Alex Zueiv   Alex Zueiv, Tashkent
May 17, 2023
Hmm… I just tried to paste it into a new file using FMP 19.6.3, and everything works fine.

This isn't the only function I have that matches the existing one, and the @ prefix works well for all of them:

@Char ( codePoint )
@Code ( character )
@GetAsDate ( text )
@JsonGetElementType ( json ; keyOrIndexOrPath )
@JsonListValues ( json ; keyOrIndexOrPath )
@TextEncode ( textToEncode ; extendedASCIIChars ; lineEndings )
@TrimAll ( text ; trimSpaces ; trimType )
@XOR ( numberOne ; numberTwo )

https://www.briandunning.com/filemaker-custom-functions/results.php?author=51669
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: