I have a table:
CREATE TABLE foo (id,lat,lon)
AS VALUES
( 1, 34, 45 ),
( 1, 45, 56 ),
( 2, 56, 67 ),
( 2, 58, 64 );
How can I get JSON like that:
{"1":[[34,45],[45,56]], "2":[[56,67],[58,64]]}
jsonpostgresql
I have a table:
CREATE TABLE foo (id,lat,lon)
AS VALUES
( 1, 34, 45 ),
( 1, 45, 56 ),
( 2, 56, 67 ),
( 2, 58, 64 );
How can I get JSON like that:
{"1":[[34,45],[45,56]], "2":[[56,67],[58,64]]}
Best Answer
First you do something like this,
That aggregates the values into an JSON Array. You get
From there you need to build an JSON Object..