Skip to content
Advertisement

ORACLE json_object_t – error when call get_string() method on object got by chain of methods .get_array() .get()

I am trying to get a value from an array contained in JSON-object by chain of methods of JSON_OBJECT_T type – .get_array(…).get(0).get_string(…)

But getting an exception component 'GET_STRING' must be declared

Here is my code, could someone explain why the chain does not work?

Advertisement

Answer

The problem is that calling .get(0) returns the type JSON_ELEMENT_T, not a JSON_OBJECT_T type. JSON_ELEMENT_T does not have GET_STRING method which is why you are getting the error.

After using get(0), you can TREAT the returned value as a JSON_OBJECT_T so that you can call the GET_STRING method.

See code below

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement