I have a JSON object that could look like the following:
{
"key1" : "value1",
"key2" : {
"messagebody" : {
"version" : "1"
},
"messageheader" : {
"reference" : "a reference"
}
}
}
This is stored in a PostgeSQL table in a column with type jsonb. My goal is now to find the field version and the field reference. But the structure of the json could vary, so eg. key2 could be named key3 in another record.
Is there a query in PostgreSQL that allow's me to give it a key and find the value of that key in the object no mather where in the object it is located?
The PostgreSQL version is 10.