-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
An example:
from:
{
"isn't": true
}This is valid json.
to:
{
"isn't": false
}This is also valid json, but running the Differ gives:
> new JsonDiffer().Differ(from, to, false)
Newtonsoft.Json.JsonReaderException : After parsing a value an unexpected character was encountered: t. Path 'path', line 1, position 33.
at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments)
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at JsonDiffPatch.Operation.Parse(String json)
at JsonDiffPatch.JsonDiffer.Build(String op, String path, String key, JToken value)
at JsonDiffPatch.JsonDiffer.CalculatePatch(JToken left, JToken right, Boolean useIdToDetermineEquality, String path)+MoveNext()
at JsonDiffPatch.JsonDiffer.CalculatePatch(JToken left, JToken right, Boolean useIdToDetermineEquality, String path)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at JsonDiffPatch.JsonDiffer.Diff(JToken from, JToken to, Boolean useIdPropertyToDetermineEquality)
I am pretty certain the error happens in
JsonDiffPatch/JsonDiffPatch/JsonDiffer.cs
Lines 26 to 27 in dd56de0
| Operation.Parse("{ 'op' : '" + op + "' , path: '" + path + "', value: " + | |
| (value == null ? "null" : value.ToString(Formatting.None)) + "}"); |
JsonDiffPatch/JsonDiffPatch/JsonDiffer.cs
Lines 30 to 31 in dd56de0
| Operation.Parse("{ op : '" + op + "' , path : '" + Extend(path, key) + "' , value : " + | |
| (value == null ? "null" : value.ToString(Formatting.None)) + "}"); |
This code creates
{ 'op' : 'replace' , path: '/isn't', value: true} which isn't valid json at all. The only reason it doesn't fail in other cases is that JObject.Parse is generous.Metadata
Metadata
Assignees
Labels
No labels