oberstet / pljson Goto Github PK
View Code? Open in Web Editor NEWPL/JSON - Forked from https://sourceforge.net/projects/pljson/
PL/JSON - Forked from https://sourceforge.net/projects/pljson/
in json_printer:
when chr(13) then buf := '\f';
when chr(14) then buf := '\r';
Form feed \f should be code 12, and carriage return \r should be 13.
Maybe same issue in json_parser which is why it works?
when 'f' then varbuf := varbuf || chr(13);
when 'n' then varbuf := varbuf || chr(10);
when 'r' then varbuf := varbuf || chr(14);
Json values are stored as varchar2, bringing in this limitation. It should be possible to use clob instead of vc2.
declare
j pljson.json;
c clob;
begin
j := pljson.json();
c := rpad(' ', 32768, ' ');
j.put('test', c);
end;
(this question along with a screen shot of the error can also be viewed here: http://stackoverflow.com/questions/27608461/oracle-pl-json-to-clob-fails)
The code below is taken directly from example file ex11.sql. All I added was the loop code for making the string larger because I wanted to test a true clob. I found it fails with certain lengths and I can't figure out why.
Any ideas on how to get this to work consistently?
ex11.sql
set serveroutput on;
declare
teststringlength pls_integer := 32763;
i pls_integer := 0;
obj json;
my_clob clob := '{"a":"';
begin
while i < teststringlength loop
my_clob := concat(my_clob,'X');
i := i + 1;
end loop;
my_clob := concat(my_clob,'"}');
obj := json(my_clob);
obj.print;
dbms_lob.trim(my_clob, 0); --empty the lob
obj.to_clob(my_clob);
dbms_output.put_line('----');
dbms_output.put_line(my_clob);
--example with temperary clob
my_clob := empty_clob();
dbms_lob.createtemporary(my_clob, true);
obj.to_clob(my_clob, true);
dbms_output.put_line('----');
dbms_output.put_line(my_clob);
dbms_lob.freetemporary(my_clob);
end;
/
Error...
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "MySCHEMA.JSON_PRINTER", line 10
ORA-06512: at "MySCHEMA.JSON_PRINTER", line 211
ORA-06512: at "MySCHEMA.JSON_PRINTER", line 238
ORA-06512: at "MySCHEMA.JSON_PRINTER", line 256
ORA-06512: at "MySCHEMA.JSON", line 274
ORA-06512: at line 16
...update...
I may have found the bug, second set of eyes would be great. In json_printer.ppMem
there is this line...
add_to_clob(buf, buf_str, llcheck('"'||escapeString(mem.get_string)||'"'));
If the string is close enough to the 32767 limit then then combination of escapeString()
and llcheck()
can cause it to grow beyond that point. escapeString()
can replace a number of single chars with 2 chars and llcheck()
adds 2 chars as well. Thus add_to_clob()
bombs because the 3rd param is a varchar2. Thoughts? Is this a bug that can be fixed in a new version?
I've just used the latest version and my JSON is littered with newline characters now when spaces is set to false. It didn't used to happen in older versions.
In JSON_PRINTER.ppString there is a "|| newline_char" which is oblivious to the spaces boolean.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.