I need this in my C code on the server side. Any link to the `jsonb_each` for this? Examples I found in a quick search are on the client side in SQL.
I am just confused about the various jsonb types and how to effectively extract values and convert between them:
There are Jsonb, JsonbValue (plus the associated JsonbPair ) to begin with. The ` JsonbToCStringWorker ` example that Andrew pointed out uses still another "JsonbContainer" type.
But the type I get from "PG_GETARG_JSONB_P" is Jsonb. And it doesn't fit into " JsonbContainer" or the pointer math about "JsonPair" that I found online.
What I am struggling with adapting some of the iterator code I saw is how to delete irrelevant code without breaking it. My use case is very restricted and handles hstore-like jsonb's.
I don't need or want the code to have the ability to descend into nested objects or handle arrays etc., as they are invalid input in my case.
I thought the pointer math example I found is easier to adapt, but I couldn't get a valid "JsonbPair" from the input parameter to feed into the pointer math.
Yeah I'm not sure why you're looping using pointer math, the iterators are there to provide that service. Another function to check out 'jsonb_each', other than the set returning function parts, it does what it looks like your are trying to do.