public interface JsonPatch
このインターフェースは、RFC 6902 で定義されている JSON パッチの不変の実装を表します。
JSON パッチでパッチ操作を指定することにより、JsonPatch
を Json.createPatch(JsonArray)
でインスタンス化できます。または、JsonPatchBuilder
で構築することもできます。
1. JSON パッチを使用して JsonPatch を構築します。
JsonArray contacts = ... // The target to be patched
JsonArray patch = ... ; // JSON Patch
JsonPatch jsonpatch = Json.createPatch(patch);
JsonArray result = jsonpatch.apply(contacts);
2. JsonPatchBuilder を使用して JsonPatch を作成します。
JsonPatchBuilder builder = Json.createPatchBuilder();
JsonArray result = builder.add("/John/phones/office", "1234-567")
.remove("/Amy/age")
.build()
.apply(contacts);
修飾子と型 | インターフェースと説明 |
---|---|
static class | JsonPatch.Operation この列挙型は、RFC 6902 で定義されている有効な JSON パッチ操作のリストを表します。 |
修飾子と型 | メソッドと説明 |
---|---|
<T extends JsonStructure> | apply(T target) 指定された target にパッチ操作を適用します。 |
JsonArray | toJsonArray() JsonPatch を JsonArray として返します。 |
<T extends JsonStructure> T apply(T target)
target
にパッチ操作を適用します。ターゲットはパッチによって変更されません。T
- ターゲット型。JsonStructure
のサブ型である必要があります target
- パッチ操作を適用するターゲット JsonException
- 提供された JSON パッチの形式が正しくない場合、または存在しないメンバーへの参照が含まれている場合 JsonArray toJsonArray()
JsonPatch
を JsonArray
として返します。JsonPatch
は JsonArray
として Copyright © 2018,2020 Eclipse Foundation.
Use is subject to license terms.