I have a column carInfo with type jsonb in one of my tables in a PostgreSQL database. A sample row looks something like this:
{
"name":"John",
"age":25,
"car":{
"brand":"KIA",
"year":2015
}
}
I know that in PostgreSQL you can query it in this way:
select * from car where carInfo -> 'name' = 'John'
but I would like to make this query dynamic (by using PostgreSQL functions or something) so that I can query it from my Java application. I want to reuse the same query even when I want to go a level deeper for example
select * from car where carInfo -> 'car' -> 'brand' = 'KIA'
Any idea how I can achieve this?