Database Reference
In-Depth Information
13:21:03.235204")
tstamp | 2012-04-30 15:42:11.757535
-[ RECORD 2
]------------------------------------
id | 6
data2 | (2,0.15740,"2012-04-05 13:21:05.2033")
tstamp | 2012-04-30 15:42:11.757535
Now, let's see how row_to_json() handles that:
hannu=# select row_to_json(t2, true) from test2
t2;
row_to_json
-----------------------------------------------------------
{"id":5,
"data2":{"id":1,"data":"0.26281",
"tstamp":"2012-04-05
13:21:03.235204"},
"tstamp":"2012-04-30 15:42:11.757535"}
{"id":6,
"data2":{"id":2,"data":"0.15740",
"tstamp":"2012-04-05 13:21:05.2033"},
"tstamp":"2012-04-30 15:42:11.757535"}
(2 rows)
The result was converted to JSON with no problems.
Just to be sure, let's push the complexity up a bit more and create a table test3 ,
which has an array of table2 rows as its data value:
create table test3(
id serial primary key,
data3 test2[],
tstamp timestamp default current_timestamp
);
Search WWH ::




Custom Search