Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alterations to json_object after parsing a JSON string are not possible #7

Open
fb-datax opened this issue Sep 27, 2016 · 2 comments
Open

Comments

@fb-datax
Copy link

fb-datax commented Sep 27, 2016

After a JSON string has been parsed into a json_object, modifications (put('field','value')) are not included in the non-raw output.

Sample code:

set serveroutput on size unlimited;
declare
    v_json          json_object;
    v_json_string   varchar(32000)      := '{"data":[{"p1":["a1",8.11],"p2":["a1",8.11]},{"p1":["a1",8.11],"p2":["a1",8.11]}]}';

begin
    v_json := json_object(v_json_string);
    json_debug.output(v_json, false);
    v_json.put('newnode','somevalue');
    json_debug.output(v_json, false); /* missing newnode*/
    json_debug.output(v_json, true); /* contains newnode*/
end;
/

The lastID in the json_obejct is not set to the last root node of the parsed json.

I did fix this in my fork but I had to include some more changes like the possibility to check to current running version. If time allows it I'll try to send a proper merge request in the next few days.
Commits:
fb-datax/PLSQL-JSON@9116883
fb-datax/PLSQL-JSON@f1b36e7

Update: Proposed fix does only works for root node

@doberkofler
Copy link
Owner

@fb-datax Could you please try using the latest release as it includes several corrections when modifying an existing json structure.

@fb-datax
Copy link
Author

The 2nd outout json_debug.output(v_json, false); still doesn't contain the newly added 'newnode'.

We did circumvent the problem with a new routine which loops through the structure and creates a fresh copy of the parsed json_object in order to be able to add new nodes and values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants