PostgreSQL Nested JSON Querying

前端 未结 1 623
情歌与酒
情歌与酒 2020-12-14 14:37

On PostgreSQL 9.3.4, I have a JSON type column called \"person\" and the data stored in it is in the format {dogs: [{breed: <>, name: <>}, {breed: <>

相关标签:
1条回答
  • 2020-12-14 15:16

    This is because operator ->> gets JSON array element as text. You need a cast to convert its result back to JSON.

    You can eliminate this redundant cast by using operator ->:

    select person->'dogs'->0->'breed' from people where id = 77;
    
    0 讨论(0)
提交回复
热议问题