JSON generation improvements.
This adds the following:
json_agg(anyrecord) -> json
to_json(any) -> json
hstore_to_json(hstore) -> json (also used as a cast)
hstore_to_json_loose(hstore) -> json
The last provides heuristic treatment of numbers and booleans.
Also, in json generation, if any non-builtin type has a cast to json,
that function is used instead of the type's output function.
Andrew Dunstan, reviewed by Steve Singer.
Catalog version bumped.

JSON generation improvements.
This adds the following:
json_agg(anyrecord) -> json
to_json(any) -> json
hstore_to_json(hstore) -> json (also used as a cast)
hstore_to_json_loose(hstore) -> json
The last provides heuristic treatment of numbers and booleans.
Also, in json generation, if any non-builtin type has a cast to json,
that function is used instead of the type's output function.
Andrew Dunstan, reviewed by Steve Singer.
Catalog version bumped.

As I wrote earlier, since 9.2 we have JSON datatype. Thanks to this commit by Andrew, it will be have more functionality.

But, if the datatype of argument has existing cast to json, this cast will be used. Currently, as far as I can tell, this works only with hstore – using hstore_to_json() function. Which looks more or less like this:

As you can see string ‘t' became boolean true, and string ‘123.45' became numeric value 123.45.

While I greatly appreciate Andrew's work, I can't seem to forget, that while we can build JSON values in Pg now, we can't really query them. That is – there is no way (aside from some crude regexp parsing) to treat json array as SQL array. Or hash as a row/record.

Still – this addition is very cool, and if you'd consider generating JSON within Pg – it will greatly simplify what you have to write.