Skip to Main Content
  • Questions
  • Strange behavior get_number for json_object_t

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Artem.

Asked: March 06, 2020 - 8:55 am UTC

Last updated: March 06, 2020 - 10:23 am UTC

Version: Oracle Database 18c

Viewed 1000+ times

You Asked

Hi, Tom.
I noticed strange behavior for json_object_t when calling get_number and my json contains an empty line
DECLARE 
   l_fav   json_object_t; 
   l_num   NUMBER; 
BEGIN 
   l_fav := json_object_t ('{"test1":"","test2":"55123"}'); 
    
   l_fav.on_error(3); 
    
   l_num := l_fav.get_number ('test1'); 
    
   DBMS_OUTPUT.put_line ('Number = ' || l_num); 
 
END;


Statement processed.
Number = 5123

Is this the correct behavior?

By decision I chose to use to_char(l_fav.get_string('test1'))
Or use null in json instead of empty string (Not always possible)

with LiveSQL Test Case:

and Chris said...

Yep, it's a bug (29216723).

It's fixed in 20c; speak to support about patches.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library