Search code examples
jsonoracleplsqloracle12cpljson

Oracle 12c PL/JSON Chopping Off Strings at 5000 Characters


I'm having an issue with PL/JSON chopping off string values at exactly 5000 characters.

Example data: {"n1":"v1","n2":"v2","n3":"10017325060844,10017325060845,... this goes on for a total of 32,429 characters ...10017325060846,10017325060847"}

After I convert the JSON string to an object I run this...

dbms_output.put_line(json_obj.get('n3').get_string);

And it only outputs the first 5000 characters. So I did some digging, see line 26 of this code. And right below it at line 31 the extended_str is being set and contains all 32,429 chars. So now let's move on to the get_string() member function. There are two of them. I verified that it's the first one that is being called, the one with the max_byte_size and max_char_size parameters. Both of those parameters are null. So why is my text being chopped off at 5000 characters? I need this to work for data strings of varchar2(32767) and clobs. Thanks!

Version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

UPDATE: I found that the chopping of the text is coming from line 35: dbms_lob.read(str, amount, 1, self.str);. I ignored this code before because I saw the comment and knew my string wasn't null. So why is this read needed? Is this a bug?


Solution

  • As maintainer of the pljson project I have answered your question on github (https://github.com/pljson/pljson/issues/154). For any further question feel free to ask on the same issue thread on github.