Hi, folks. I’m having trouble parsing a single, simple and predictable JSON response before doing an insert in RESTful Services in APEX. The good part is that I have access to the :body variable, and all the first-level attributes of the object (var1 and var2 in the below sample object, but the trouble comes in when I try to get the values of a known embedded object within the response (var3 and var4 in the below response.
{
"var1": "XXXXX",
"var2": "YYYYY",
"payload": {
"var3": "ZZZZZ",
"var4": 12345
}
}
I have tried using dot notation (:body.payload.var3, :payload.var3, etc.) with no luck. I am able to convert the incoming blob to a local clob and use it the same as :body, but still cannot drill down into it. I am aware of tools like apex_json.parse, get_%, find_paths_like, but I’m still fairly new to APEX, PL/SQL and Procedures, let alone all the built in APIs, so I’m not sure which is the correct method to use.
I feel like the answer could be REALLY simple, the same way that the :body variable is, but it could also be as complex and writing a procedure that declares a bunch of variables, converts the incoming blob to a clob, loops through it and assigns the values found to the declared variables, then using those variables in an INSERT statement.
I really am looking to be pointed in the right direction, and I’m so close. Please help if you can. Much appreciated!