コード例 #1
0
        public void Copy_property()
        {
            var sample = PatchTests.GetSample2();

            var patchDocument = new PatchDocument();
            var frompointer   = new JsonPointer("/books/0/ISBN");
            var topointer     = new JsonPointer("/books/1/ISBN");

            patchDocument.AddOperation(new AddOperation()
            {
                Path = frompointer, Value = new JValue("21123123")
            });
            patchDocument.AddOperation(new CopyOperation()
            {
                FromPath = frompointer, Path = topointer
            });

            var patcher = new JsonPatcher();

            patcher.Patch(ref sample, patchDocument);

            var result = new JsonPointer("/books/1/ISBN").Find(sample);

            Assert.AreEqual("21123123", result.Value <string>());
        }