I have a table that holds a column called additional_info.
this column contains a JSON object that looks like that:
{
"dbSources": [{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.68",
"database": "xe",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
},{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.69",
"database": "xe1",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
}]
}
I want to extract (to select) the value of "database" where srcIp equals 10.10.10.68.
meaning I want to extract the value "xe" from the first JSON object under the JSON array called dbSources.
The only thing that I could do is
select additional_info::json ->'dbSources' as db from table
but how can I continue from there?