aspnet / JsonPatch

[Archived] JSON PATCH library. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
103 stars 48 forks source link

Add builtin JObjectAdapter that implements IAdapter #84

Closed maximpashuk closed 7 years ago

maximpashuk commented 7 years ago

As for now builtin implementations for IAdapter are

DictionaryAdapter ExpandoObjectAdapter ListAdapter PocoAdapter

In my case is useful to have JsonPatchDocument<JObject> and apply it to JObject from Newtonsoft.Json.

I use workaround

var expandoObject = new ExpandoObject();
patchDoc.ApplyTo(expandoObject);
var jObject = JObject.FromObject(expandoObject);

However, it would be nice to have builtin IAdapter for JObject so I can call

var jObject = new JObject();
patchDoc.ApplyTo(jObject)

without any errors.

maximpashuk commented 7 years ago

Also I found that issue #75 can be fixed if support for JObject will be added.

patch.ApplyTo(JObject.Parse("{"region": "amer", "foo1": {"foo11": "val1", "foo12": 2}}"));
Eilon commented 7 years ago

Looks like this would be covered by https://github.com/aspnet/JsonPatch/issues/38.