共用方式為


IObjectAdapter 介面

定義

定義可在 JSON 修補檔上執行的作業。

public interface class IObjectAdapter
public interface IObjectAdapter
type IObjectAdapter = interface
Public Interface IObjectAdapter
衍生

方法

Add(Operation, Object)

使用 「add」 作業,新值會插入目的檔案的根目錄、位於指定有效索引的目標陣列,或插入指定位置的目標物件。

新增至陣列時,指定的索引不可大於陣列中的元素數目。 若要將值附加至陣列,則會使用 「-」 字元的索引, (請參閱 [RFC6901]) 。

新增至物件時,如果物件成員不存在,則會將新的成員新增至指定位置的物件,或者如果物件成員存在,則會取代該成員的值。

工作物件必須包含「值」成員,其內容會指定要加入的值。

例如:

{ 「op」: 「add」, 「path」: 「/a/b/c」, 「value」: [ 「foo」, 「bar」 ] }

請參閱 RFC 6902 https://tools.ietf.org/html/rfc6902#page-4

Copy(Operation, Object)

使用「複製」作業,值會從指定的位置複製到目標位置。

工作物件必須包含 「from」 成員,該成員會參考目的檔案中要複製值的位置。

「寄件者」位置必須存在,才能讓作業成功。

例如:

{ 「op」: 「copy」, 「from」: 「/a/b/c」, 「path」: 「/a/b/e」 }

請參閱 RFC 6902 https://tools.ietf.org/html/rfc6902#page-7

Move(Operation, Object)

使用「移動」作業,會移除位於指定位置的值,並新增至目標位置。

工作物件必須包含 「from」 成員,該成員會參考目的檔案中要從中移動值的位置。

「寄件者」位置必須存在,才能讓作業成功。

例如:

{ 「op」: 「move」, 「from」: 「/a/b/c」, 「path」: 「/a/b/d」 }

位置無法移至其中一個子系。

請參閱 RFC 6902 https://tools.ietf.org/html/rfc6902#page-6

Remove(Operation, Object)

使用 「移除」作業,就會移除目標位置上的值。

必須存在目標位置,才能讓作業成功。

例如:

{ 「op」: 「remove」, 「path」: 「/a/b/c」 }

如果從陣列移除專案,則指定索引上方的任何元素會向左移一個位置。

請參閱 RFC 6902 https://tools.ietf.org/html/rfc6902#page-6

Replace(Operation, Object)

使用 「replace」 作業,目標位置上的值會取代為新的值。 工作物件必須包含指定取代值的 「value」 成員。

必須存在目標位置,才能讓作業成功。

例如:

{ 「op」: 「replace」, 「path」: 「/a/b/c」, 「value」: 42 }

請參閱 RFC 6902 https://tools.ietf.org/html/rfc6902#page-6

適用於