Open ankis2 opened 1 year ago
We are using version 13.0.2
Please provide a code example reproducing the problem that does NOT use unknown code/functions like SerializationHelper.Serialize, SerializationHelper.Deserialize and SerializationHelper.settings. Don't leave anybody blindguessingf what these do...
Preferably, provide a code example directly runnable on https://dotnetfiddle.net/
That said, i guess(!) that since Uri's get serialized as json strings and not as json objects, JObject.FromObject is not appropriate here. Try JToken.FromObject(uri)
instead (which should result in a JValue and not a JObject, since JValue is used to represent "simple" json value types like strings, numbers, booleans that are not complex/composite values like json arrays or json objects.)
Source/destination types
Source/destination JSON
{https://localhost/}
Expected behavior
Uri uri = new Uri("https://localhost"); Uri dce2 = SerializationHelper.Deserialize(SerializationHelper.Serialize(uri));
JToken.DeepEquals(
JObject.FromObject(uri, JsonSerializer.Create(SerializationHelper.settings)),
JObject.FromObject(dce2, JsonSerializer.Create(SerializationHelper.settings)));
}
JObject.FromObject fails with error: Object serialized to Uri. JObject instance expected.'
I expected the JObject.FromObject to work without issues for both of the original issue and the roundtrip version.
Actual behavior
Steps to reproduce