Provides JSON serialization and deserialization functions for use in HotMesh mapping rules. Although inspired by JavaScript, they have been adapted to follow a functional approach. Each transformation is a function that expects one or more input parameters from the prior row in the @pipe structure.

Invoked in mapping rules using {@json.<method>} syntax.

Constructors

Methods

Constructors

Methods

  • Parses a JSON string and returns the resulting JavaScript object. Wraps JSON.parse with support for an optional reviver function.

    Parameters

    • text: string

      The JSON string to parse

    • Optionalreviver: ((this: any, key: string, value: any) => any)

      A function that transforms the results, called for each key-value pair

        • (this, key, value): any
        • Parameters

          • this: any
          • key: string
          • value: any

          Returns any

    Returns any

    The JavaScript value parsed from the JSON string

    js_object:
    "@pipe":
    - ["{a}"]
    - ["{@json.parse}"]
  • Converts a JavaScript object or value to a JSON string. Wraps JSON.stringify with support for optional replacer and space parameters for pretty-printing.

    Parameters

    • value: any

      The value to convert to a JSON string

    • Optionalreplacer: ((this: any, key: string, value: any) => any)

      A function that alters the behavior of the stringification process, or an array of strings and numbers to filter properties

        • (this, key, value): any
        • Parameters

          • this: any
          • key: string
          • value: any

          Returns any

    • Optionalspace: string | number

      A string or number used to insert whitespace for readability

    Returns string

    The JSON string representation of the value

    json_string:
    "@pipe":
    - ["{a}", null, 2]
    - ["{@json.stringify}"]