Chapman Flack <c...@anastigmatix.net> writes: > On 12/17/20 14:28, Tom Lane wrote: >> If you're imagining that js['n'] and js['v'] would emit different >> datatypes, forget it. That would require knowing at parse time >> what the structure of the json object will be at run time.
> Would it be feasible to analyze that as something like an implicit > 'treat as' with the type of the assignment target? TBH, I think that expending any great amount of effort in that direction would be a big waste of effort. We already have strongly-typed composite types. The use-case for json is where you *don't* have ironclad guarantees about what the structure of the data is. As for doing it implicitly, that is still going to fall foul of the fundamental problem, which is that we don't have the info at parse time. Examples with constant values for the json input are not what to look at, because they'll just mislead you as to what's possible. regards, tom lane