I want to add properties to an existing instance of JsonObject. If this property is boolean, this is quite easy:
JsonObject
boolean
JsonObject jo = ..
Try using JsonPatch
String json ="{\"name\":\"John\"}"; JsonObject jo = Json.createReader(new StringReader(json)).readObject(); JsonPatch path = Json.createPatchBuilder() .add("/last","Doe") .build(); jo = path.apply(jo); System.out.println(jo);