I'm working on an event that compares the jsonb values within a column between the last entry and the new entry. I have another table that defines what values to compare by passing on a jsonb object itself. What I'm working with goes something like this:
select jsonb_extract_path(_tmp_jsonb, 'key_1', 'key2') into target;
and the jsonb object I'm looking inside is this:
{
"key1": {"key2": 15},
"key3": {"key2": {"key4": 25}}
}
Now I can get 15 with the above command no problem, but what I'd like to do is be able pass any key combinations as a jsonb array like {"search_keys":["key3", "key2", "key4"]}
. So something like this:
select jsonb_extract_path(_tmp_jsonb, ["key3", "key2", "key4"]) into target;
More clearly, what I'm asking is how to use variable length argument arrays in postgres, as you would do in python with *args.