Convert a temporal JSONB to a tstzspan
tjsonb::tstzpan
SELECT tjsonb '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]'::tstzspan;
-- [2001-01-01, 2001-01-02]
Convert between a temporal JSONB and a text
tjsonb::text
text::tjsonb
SELECT (text '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]')::jsonb;
/* [{"location": "Point(1 1)", "vehicleId": 1}@2001-01-01,
{"location": "Point(2 2)", "vehicleId": 1}@2001-01-02] */
SELECT pg_typeof(tjsonb '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]'::text);
-- text
Convert between a temporal JSONB and a temporal text
tjsonb::ttext
ttext::tjsonb
SELECT (ttext '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]')::tjsonb;
/* [{"location": "Point(1 1)", "vehicleId": 1}@2001-01-01,
{"location": "Point(2 2)", "vehicleId": 1}@2001-01-02] */
SELECT pg_typeof(tjsonb '[{"vehicleId": 1, "location": "Point(1 1)"}@2001-01-01,
{"vehicleId": 1, "location": "Point(2 2)"}@2001-01-02]'::ttext);
-- ttext