简体   繁体   中英

Postgres ad nested json

I am trying to parse a field from a nested JSON using postgresql. The form of a JSON has the following form:

{"Field_1": {"Field_2": {"Field_3": "value_1": "xxx"}}}

I have read the question How do I query using fields inside the new PostgreSQL JSON datatype? and I have searched the proposed links, but I have not found anything to work.

{"Field_1": {"Field_2": {"Field_3": "value_1": "xxx"}}}

I want to parse the xxx of value_1 .

Your JSON have incorrect syntax, this is correct one:

{"Field_1": {"Field_2": {"Field_3": {"value_1": "xxx"}}}}

Then you can:

select j->'Field_1'->'Field_2'->'Field_3'->'value_1' from (
    select '{"Field_1": {"Field_2": {"Field_3": {"value_1": "xxx"}}}}'::jsonb as j
) t

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM