Modifying the parsed JSON doc...

Issue #6 resolved
Clive Haworth created an issue

I need to be able to merge two JSON docs and couldn't find this functionality in the API, so I'm rolling my own.

I'm using this approach:

JSON json = JSON.parse(new FileInputStream("app.cfg")); JSON.Object module = (JSON.Object) json.get("modules").get("module"); module.put("port", new JSON.Numeric(1024));

I expected this to replace the node. In fact it is adding a duplicate node.

Am I doing something wrong here?

Regards Clive

Comments (3)

  1. John Marsden repo owner
    • edited description

    JSONiJ allowed two keys with the same value to be present in the object. This is not possible on any object implementation I know of and it is unhelpful for query languages.

    This is fixed in my current working version. I know this issue was raised a long time ago but you are welcome to it if you want it (drop me a line if you want it).

    John

    P.S. There are easier ways to index into that path but I am guessing you have moved on by now.

  2. Log in to comment