JSON Functions

  • Capella Columnar
  • reference
    +
    This topic describes the builtin SQL++ for Capella columnar JSON functions.

    decode_json

    • Syntax:

      decode_json(expr)
    • Unmarshals the JSON-encoded string into a SQL++ for Capella columnar value.

    • Arguments:

      • expr: a JSON-encoded string.

    • Return Value:

      • A SQL++ value.

      • If expr is NULL or an empty string then NULL is returned.

      • If expr is MISSING then MISSING is returned.

    • Example:

      decode_json("{\"abc\":1,\"def\":2}");
    • The expected result is:

      {
        "abc": 1,
        "def": 2
      }

    encode_json

    • Syntax:

      encode_json(expr)
    • Marshals the SQL++ for Capella columnar value into a JSON-encoded string.

    • Arguments:

      • expr: a SQL++ value.

    • Return Value:

      • A JSON-encoded string.

      • If expr is NULL then NULL is returned.

      • If expr is MISSING then MISSING is returned.

    • Example:

      encode_json({"abc":1,"def":2});
    • The expected result is:

      "{ \"abc\": 1, \"def\": 2 }"

    encoded_size

    • Syntax:

      encoded_size(expr)
    • Returns the number of bytes in an uncompressed JSON encoding of the value. The exact size is implementation-dependent.

    • Arguments:

      • expr: a SQL++ value.

    • Return Value:

      • An integer. Never MISSING or NULL. Returns 0 for MISSING.

    • Example:

      encoded_size({"abc":1,"def":2});
    • The expected result is:

      22