 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Importance of the JsonPatch interface in Java?
The JsonPatch interface is a format for storing a sequence of operations that can be applied to the target JSON structure. There are few operations like add, remove, replace, copy, move and test can be stored in JsonPath and operated on JSON structure. The JsonPatchBuilder interface can be used for constructing a JSON patch using the Json.createPatchBuilder().
JSON file
Example
import java.io.*; import javax.json.Json; import javax.json.JsonPatch; import javax.json.JsonPatchBuilder; import javax.json.JsonReader; import javax.json.JsonStructure; public class JsonPatchTest {    public static void main(String[] args) throws Exception {       JsonPatchBuilder jsonPatchBuilder = Json.createPatchBuilder();       JsonPatch jsonPatch = jsonPatchBuilder.add("/postalCode", "500072").remove("/age").build();       JsonReader reader = Json.createReader(new FileReader("simple.json"));       JsonStructure jsonStructure1 = reader.read();       JsonStructure jsonStructure2 = jsonPatch.apply(jsonStructure1);       System.out.println(jsonStructure2);       reader.close();    } } Output
{"firstName":"Raja","lastName":"Ramesh","streetAddress":"Madhapur","city":"Hyderabad","state":"Telangana","phoneNumbers":[{"Mobile":"9959984000"},{"Home":"7702144400"}],"postalCode":"500072"}Advertisements
 