So I've read through the Postgres JSON querying examples and I'm pretty sure there's no way to query our data as structured, but I wanted to make absolutely sure as it will require multiple changes to our code base :)
We are currently storing the following data in a serialized text field in Postgres. We would like to be able to query against the values, which are either nil
or arrays-of-hashes [{a : 1, b: 2},{c: 3, d: 4}]
to see if the hash values themselves contain a hash witch has a certain value (in the example below facebook
or 102
).
{ "statuses": nil,
"services_and_accounts": [
{
"id": "facebook",
"enabled": false
},
{
"id": 102,
"enabled": false
}
]
}
Is this possible in pure SQL using the JSON datatype?