Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSON - How to ensure a deep node exists?

Mike KutzMar 19 2022

Given JSON:

j json_object_t := new json_object_t(
    q'[{"Wabbit":{"BugsBunny":{"action":"eat a carrot","statement":"Ehh..? What's up Doc?"}}}]' );

How do I check that the node $.Wabbit.BugsBunny.action exists within PL/SQL?
I am trying to avoid converting it to a CLOB and use JSON_TABLE() or JSON_EXISTS
I tried j.has('Wabbit.BugsBunny.action') but that didn't work.
Do I have to recursively fetch and check each node in a loop? ( j.has('Wabbit') returns TRUE as expected )
Database: 21c ATP Free Tier
Thanks,
MK

This post has been answered by padders on Mar 19 2022
Jump to Answer
Comments
Post Details
Added on Mar 19 2022
8 comments
629 views