Return the Well-Known Text (WKT) representation
asText({tjsonb,tjsonb[]}) → {text,text[]}
SELECT asText(tjsonb '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]');
/* ["{\"location\": \"Point(1 1)\", \"vehicleId\": 1}"@2001-01-01, "{\"location\":
\"Point(2 2)\", \"vehicleId\": 1}"@2001-01-02] */
SELECT asText(ARRAY[tjsonb '"{\"vehicleId\":1, \"location\": \"Point(1 1)\"}"@2001-01-01',
'"{\"vehicleId\": 1, \"location\": \"Point(2 2)\"}"@2001-01-02']);
/* {"\"{\\\"location\\\": \\\"Point(1 1)\\\", \\\"vehicleId\\\":
1}\"@2001-01-01","\"{\\\"location\\\": \\\"Point(2 2)\\\", \\\"vehicleId\\\":
1}\"@2001-01-02"} */
As can be seen above, for arrays of JSONB values, the elements must be enclosed between quotes and thus, the inner quotes must be escaped.
Return the Well-Known Binary (WKB) or the Hexadecimal Well-Known Binary (HexWKB) representation
asBinary(tjsonb,endian text='') → bytea asHexWKB(tjsonb,endian text='') → text
The result is encoded using either the little-endian (NDR) or the big-endian (XDR) encoding. If no encoding is specified, then the encoding of the machine is used.
SELECT asBinary(tjsonb '"{\"vehicleId\": 1, \"location\": \"Point(1 2)\"}"@2001-01-01');
/* \x0142000138000000000000000200002008000080090000000a000000090000106c6f636174696f6e76
656869636c654964506f696e7428312032290020000000008001000040eba9c21c0000 */
SELECT asHexWKB(tjsonb '"{\"vehicleId\": 1, \"location\": \"Point(1 2)\"}"@2001-01-01');
/* 0142000138000000000000000200002008000080090000000A000000090000106C6F636174696F6E7665
6869636C654964506F696E7428312032290020000000008001000040EBA9C21C0000 */
Return the Moving Features JSON (MF-JSON) representation
asMFJSON(text) → tjsonb
SELECT asMFJSON(tjsonb '[{"Position": "Point(1 1)"}@2001-01-01,
{"Position": "Point(2 2)"}@2001-01-02]');
/* {"type":"MovingJsonb","values":[{"Position": "Point(1 1)"},{"Position": "Point(2
2)"}],"datetimes":["2001-01-01T00:00:00","2001-01-02T00:00:00"],"lower_inc":true,"up
per_inc":true,"interpolation":"Step"} */
Input from the Well-Known Text (WKT) representation
tjsonbFromText(text) → tjsonb
SELECT tjsonbFromText(text '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]');
/* ["{\"location\": \"Point(1 1)\", \"vehicleId\": 1}"@2001-01-01, "{\"location\":
\"Point(2 2)\", \"vehicleId\": 1}"@2001-01-02] */
Input from the Well-Known Binary (WKB) or from the Hexadecimal Well-Known Binary (HexWKB) representation
tjsonbFromBinary(bytea) → tjsonb tjsonbFromHexWKB(text) → tjsonb
SELECT tjsonbFromBinary(asBinary( tjsonb '[{"vehicleId": 1,
"location": "Point(1 2)"}@2001-01-01]'));
-- ["{\"location\": \"Point(1 2)\", \"vehicleId\": 1}"@2001-01-01]
SELECT tjsonbFromHexWKB(asHexWKB( tjsonb '[{"vehicleId": 1,
"location": "Point(1 2)"}@2001-01-01]'));
-- ["{\"location\": \"Point(1 2)\", \"vehicleId\": 1}"@2001-01-01]
Input from the Moving Features JSON (MF-JSON) representation
tjsonbFromMFJSON(text) → tjsonb
SELECT tjsonbFromMFJSON('{"type": "MovingJsonb", "interpolation": "Step",
"values": [{"Position": "Point(1 1)"}, {"Position": "Point(2 2)"}],
"datetimes": ["2001-01-01T10:00:00", "2001-01-01T12:00:00"]}');
/* ["{\"Position\": \"Point(1 1)\"}"@2001-01-01 10:00:00, "{\"Position\": \"Point(2
2)\"}"@2001-01-01 12:00:00] */