Skip to content
Advertisement

change the json object value

JavaScript

I have a json object like above and i want to change apiInvokerPublicKey’s value i did not find a method in gson so how can i change it?

JavaScript

EDIT: I used addProperty method from gson but it changes whole “onboardingInformation” i just want to change “apiInvokerPublicKey”

Advertisement

Answer

You can read whole JSON payload as JsonObject and overwrite existing property. After that, you can serialise it back to JSON.

JavaScript

Above code prints:

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