Processing JSON using JSON Patch

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:

  1. Read the target JSON document using JsonReader
  2. Instantiate PatchBuilder
  3. Use PatchBuilder to add gender data
  4. Use PatchBuilder to remove hiredate
  5. 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); ...

Get RESTful Java Web Services - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.