Built-in JSON Functions

Idea created by Chris Irvine on Oct 26, 2015
    Delivered
    Score175

    JSON is the de facto lightweight standard for exchanging data on the web.

     

    FileMaker should expand the library of built-in functions to support some simple functions to assemble JSON strings and also functions to retrieve data from existing JSON strings.

     

    Solutions have already been proposed in public space as scripts and custom functions. However, native functions would provide better performance and encourage standardization. The main industry use for JSON is to produce and/or consume web services, already a core component of many FileMaker solutions. The second and crucial benefit would be for encoding "multiple parameters" for passing through the script parameter and script result. This serialization technique has a multitude of additional applications.

     

     

    I'm not to particular about which functions are included, but a few ideas for inspiration:

     

    Encoding

     

    // Credit to  Dan Smith - See: https://github.com/dansmith65/FileMaker-JSON-Functions

    jsonA(), jsonAv(), jsonO(), jsonOp() // handles escaping and syntax; could handle property replacement

     

    Decoding

     

    // Inspired by some Java related functions

    jsonNumber(json, name) // returns number for property having name

    jsonText(json, name) // returns text string for property having name

    jsonObject(json, name) // returns another JSON string, for property having name

     

    // Eating some of the cake

    jsonNumberArrayIntoRepetitions(json_array, local_var)

    jsonTextArrayIntoRepeititions(json_array, local_var) // replaces all $local_var repetitions with data decoded from json

     

    // A little coffee with that cake

    repetition_numbers(local_var) // returns a list of repetition numbers for non-blank repetitions of $local_var. Inspired by array_keys()

     

    A hard problem... dates, times, and timestamps. Might I recommend ISO 8601.