Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I'm using your code to generate JSON objects, it works great! I've found that if you try to add an array object without any members, you get a:
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "JOSE.JSON", line 225
This is because in line 225 of json_body.typ you are looping like this:
FOR j IN 1..v_json_element_array.LAST
Since v_json_element_array is not defined, you have a numeric or value error there.
I've modified the script to add an if check before looping:
LINE 225: IF v_json_element_array.COUNT > 0 THEN FOR j IN 1..v_json_element_array.LAST
LINE 292: END LOOP; END IF;
Now the array in the json text shows up like this:
I first thought of not showing the array at all to bypass the problem, but I needed to print the empty array because the libraries I'm using (google visualization) need the empty .
The better is to do like other code in same type body:
FOR j IN 1..nvl(v_json_element_array.LAST,0)
The simpler the better.
Thanks. I've done several other changes, for example I've included the date datatype and other minor fixes (for installing, since that out of the box the installation fails).
I've lost the track of what I've added, but if you want I can send you the full code so you can merge it.