-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Json.NET throws exception while deserializing relative Uri #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The reason was that over the years i've had many people surprised by the fact that So build in support to do that instead of having folks write their own json converter made sense. I could make it the Uri serialization optin/optout through Ping @crunchie84 for his thoughts as well since he wrote the PR for it initially. |
My initial PR was only for making the Uri <=> String json conversion easier. If this is a headache for the majority of uses of Nest i would recommend setting it default to serialize Uri's to string. Since 1.0.0 release of Nest introduces a lot of other breaking changes for the better this seems the moment to do so. People can still override the (new) default serialization behaviour by implementing |
@Mpdreamz Uris are serialized to strings since at least Newtonsoft.Json 5.0.8, the oldest version I currently have available. class Foo {
public Uri X { get; set; }
}
JsonConvert.SerializeObject(new Foo { X = new Uri("http://www.google.com") }); serializes to |
Ok will investigate further, at the time of this commit we were on |
By removing the custom UriJsonConverter which was put in place to serialize uris to strings by default, however Json.NET already does this out of the box. Closes #629
I've confirmed that Json.NET does indeed serialize I don't doubt that there was probably once a good reason for it, but as it stands now I can't reproduce a case where a |
This bug was introduced with commit df2bfc9.
The problem is that the Uri is created without a UriKind, thus implicitly using UriKind.Absolute, which throws an exception for relative Uris.
Is there a compelling reason to replace the standard [non-buggy] serializer?
The text was updated successfully, but these errors were encountered: