This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
JSONPatch
温绍锦 edited this page Jun 14, 2020
·
1 revision
在fastjson 1.2.71版本后,支持JSONPatch ( http://jsonpatch.com/ ).
package com.alibaba.fastjson;
public class JSONPatch {
public static String apply(String original, String patch);
public static Object apply(Object object, String patch);
}
String original = "{\n" +
" \"baz\": \"qux\",\n" +
" \"foo\": \"bar\"\n" +
"}";
String patch = "[\n" +
" { \"op\": \"replace\", \"path\": \"/baz\", \"value\": \"boo\" },\n" +
" { \"op\": \"add\", \"path\": \"/hello\", \"value\": [\"world\"] },\n" +
" { \"op\": \"remove\", \"path\": \"/foo\" }\n" +
"]";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner