Skip to content
Advertisement

How to add subnode to json file using json-simple

I create json file with the folloing code:

JavaScript

OUTPUT:

JavaScript

How can I add content of java map to the this json output as a new node sothat I have at the end the following output:

JavaScript

Advertisement

Answer

You just need to add another object of type JsonObject and it will do that

JavaScript

And that will return the output what you want

In case you need add more fields without a object a good practice its do the next:

JavaScript

This return:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement