Need support for strings containing quote characters.
This code fails with a JSON parse error because the quotes are not escaped.
j json := json();
j := json(to_char(jc));
You're right. That's an error.
The string input should be validated and possibly be corrected.
The "bug" persist in the new version - here's why:
There's no way to know whether a varchar2 is intended to be escaped or not. But there is a way to tell if it is a valid JSON-string (version 0.9 code):
json_parser.parse_any( '"' || str || '"' )
Adding escapes to an already escaped string would cause it to be double-escaped. It is also slow to escape chars in a string (not just a search replace for " and \") and I would like the JSON impl. to be fast.
Perhaps you could write to functions: escape and unescape that ensures proper escaping according to the control characters in the json standard.
i have string like 12/10/2010 and when i print de string returns 12\/10\/2010 how can i do to get 12/10/2010?
i have change when chr(47) then buf := '\/'; by when chr(47) then buf := '/'; in json_printer.
i don`t kwon it can take more problems but until now works.
You're right: the character solidus ( / ) does not need to be escaped. The output "12\/10\/2010" is correct but I will add an option so that you can disable escapement for solidus.
Just out of interest: What platform is receiving our json-text?
I am creating a json in oracle and after i print it in a browser its something like a tree directories, its works but when i pass the lenght of varchar2 don`t work,
can i save it in a clob and print it all?
Yes - just use the to_clob function on json, json_list or json_value.
You could also grab the output from dbms_output.
Log in to post a comment.