You need to sign in to do that
Don't have an account?
Vivek_Patel
Updating the existing JSON
Hi,
I am trying to update a exiting JSON structure, but I couldn't find any method or way to do that.
This is how I am creating the JSON
and now I want to update the existing "action" field's value and write some new fields in the same JSON.
Does apex support this?
I am trying to update a exiting JSON structure, but I couldn't find any method or way to do that.
This is how I am creating the JSON
JSONGenerator generator = JSON.createGenerator(true); generator.writeStartObject(); generator.writeStringField('action', 'VerifyEmail'); generator.writeEndObject(); System.debug(generator.getAsString());
and now I want to update the existing "action" field's value and write some new fields in the same JSON.
Does apex support this?
Please deserialize your JSON in Map and then add new Field using put method of Map.
and again serialize it.
Thanks!