The following example reads the JSON representation of the employee object from the emp.json file and uses the javax.json.JsonPatch API to add the gender value and remove hiredate inside the JSON document:
- Read the target JSON document using JsonReader
- Instantiate PatchBuilder
- Use PatchBuilder to add gender data
- Use PatchBuilder to remove hiredate
- Construct and apply patch operations on the target JSON document
The implementation of the previous steps is demonstrated in the following program:
public class JSR374JsonPatchExample { private static final Logger logger = Logger.getLogger(JSR374JsonPointerExample.class.getName()); public static void main(String[] args) throws IOException { logger.setLevel(Level.INFO); ...