I have a PL/SQL handler using the SODA package to manipulate a JSON database. I want to:
- Read the value for key
id
in the payload - Write the payload JSON into a new document in the database.
To do step 1, The handler takes :body
to be parsed as a JSON_OBJECT_T type, so that I can access the value for key id
in the payload.
But for step 2, if I read body
again when constructing with SODA_DOCUMENT_T(b_content=> :body)
, it will simply give me a blank document.
I also can't pass in the JSON_OBJECT_T variable in directly, like SODA_DOCUMENT_T(j_content=> jso)
, because that function expects a JSON type and not a JSON_OBJECT_T. I can't find the JSON type documentation, but saw in code examples the function JSON('{}')
to generate one.
Reading :body_text
however gives me other problems - because JSON()
function cannot handle line breaks in the payload and gives an error instead.
Currently to work around this I'm using the following:
SODA_DOCUMENT_T(
j_content => JSON(jso.to_string())
)
Which seems very silly because I'm serialising it to a string again before converting it back into JSON type. Is there a proper way to read the value of a key of the payload, and pass it into the SODA_DOCUMENT_T?