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 Extended 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');
-- \x0141000138000000000000000200002008000080090000000a000000090000106c6f636174696f6e7...
SELECT asHexWKB(tjsonb '"{\"vehicleId\": 1, \"location\": \"Point(1 2)\"}"@2001-01-01');
-- 0141000138000000000000000200002008000080090000000A000000090000106C6F636174696F6E7...
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+01","2001-01-02T00:00:00+01"],
"lower_inc":true,"upper_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": "MovingJSON", "interpolation": "Step",
"values": [{"Position": "Point(1 1)"}, {"Position": "Point(2 2)"}],
"datetimes": ["2001-01-01T10:00:00Z","2001-01-01T12:00:00Z"]}');
/* [{"Position": "Point(1 1)"}@2001-01-01 11:00:00+01,
{"Position": "Point(2 2)"}@2001-01-01 13:00:00+01] */
Convert a temporal JSONB value to the Arrow C Data Interface and back, returning the reconstructed value
arrowRoundtrip(tjsonb) → tjsonb
SELECT arrowRoundtrip(tjsonb '1@2001-01-01'); /* "1"@2001-01-01 */