to_json documentation wrt. casts is misleading - Mailing list pgsql-bugs

From Jan Hamal Dvořák
Subject to_json documentation wrt. casts is misleading
Date
Msg-id 61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz
Whole thread Raw
List pgsql-bugs
Hi,

documentation for functions `to_json` and `to_jsonb` states:

 > Arrays and composites are converted (recursively) to arrays and 
objects; otherwise, if there is a cast from the type to json, the cast 
function will be used to perform the conversion; otherwise, a scalar 
value is produced. For any scalar type other than a number, a Boolean, 
or a null value, the text representation will be used, in such a fashion 
that it is a valid json or jsonb value.

This might get interpreted in the sense that "if there is a cast from 
the type to json, the cast function will be used to perform the 
conversion" regardless of whether the value is an "array or composite".

     https://stackoverflow.com/questions/35688503/

Would it be possible to adjust the wording in a way that makes this more 
clear?

Or, alternatively, would it be possible to make use of implicit casts in 
all cases so that the distinction needs not to be made?

Best regards
Jan Hamal Dvořák



pgsql-bugs by date:

Previous
From: Gopichand Gatte
Date:
Subject: Regarding PostgreSQL
Next
From: Michael Meskes
Date:
Subject: Re: BUG #15176: ecpg generation error