-
-
Notifications
You must be signed in to change notification settings - Fork 748
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
plug different JsonSerializer or different SerializationSettings #27
Comments
It's not possible at the moment, not a bad idea for a PR though |
Which one do you prefer? Enviado pelo meu Windows Phone From: Paul Bettsmailto:notifications@github.com It's not possible at the moment, not a bad idea for a PR though Reply to this email directly or view it on GitHub: |
If someone had most of this done, hypothetically, and had a method that looked like this
What method would you prefer for defining the pluggable converters? Right now I'm thinking app.config + Activator, but I could see a case for using Windsor or MEF as a CSL, reading the type to use from app.config, and fetching it from Windsor (defaulting to JSON.Net if no pluggable converter is defined) Also thinking that the For method could take a "serialize" and "deserialize" Func as overloads rather than tying ReFit to any other JSON serializers, even indirectly. |
Let's not get crazy here. public static class RefitSettings
{
public static Func<JsonSettings> GetJsonSettings { get; set; }
} |
soooooo
? |
No. Let's stay with json.net and just update the settings. :D |
@skoon Isn't |
Ah, I think there's some crosstalk here. What I'm talking about is plugging in different JSON serializer/deserializers. So using the ServiceStack JSON serializer instead of JSON.net. You guys are talking about just changing the settings/type converters for JSON.Net. Gotcha. So this became less interesting to me if it's just passing in type converters. |
That's probably my fault. For my problem, custom JsonSerializerSettings will do. |
We could do that too, though I'm not as super excited about that. |
I was also pretty keen to get this implemented until I discovered it's actually already possible using Json.NET with almost exactly the same approach: JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
// Custom settings...
}
await api.CreateUser(new User()); // Uses custom settings. Just like magic. The only reason you might need a No harm in doing it though I guess, but just using the above approach is good enough for the app I'm working on. I was wondering though if it might be a better idea to implement something like the following: public static class RefitSettings
{
public static Func<object, string> SerializeToJson { get; set; }
// Can't use DeserializeFromJson<T> here because it's a property,
/// so the calling code would need to cast.
public static Func<string, object> DeserializeFromJson { get; set; }
} That would allow you to plug in a different serializer if you wanted to, which should help @skoon out, and would allow you to isolate the Json.NET settings if you stick with that. |
Anyone want's to pick up on this one? I like the retrofit approach to this, creating a fluent builder: |
I've created a pull request to take a stab at this issue as well . #80 |
This was closed by #80. |
is this possible? From what i saw: no, but i could be wrong.
Do you guys think its worth doing?
We're using refit but we have to serialize stuff with TypeNameHandling.All.
Currently, we're sending just strings and serializing before sending the request
If you guys this is something worth doing, i can try to implement it :)
The text was updated successfully, but these errors were encountered: