-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Changed JsonDeserializer to look for and honor DeserializeAs attribute #406
Conversation
@@ -71,7 +71,24 @@ private void Map(object target, IDictionary<string, object> data) | |||
{ | |||
var type = prop.PropertyType; | |||
|
|||
var name = prop.Name; | |||
//var name = prop.Name; | |||
string name = String.Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation. RestSharp uses tabs instead of spaces. I know! It's a travesty. I haven't gotten around to fixing it yet.
Looks good! Just a couple minor tweaks suggested. |
Tweaked based on feedback. |
@@ -192,6 +192,18 @@ public void Can_Deserialize_Elements_to_Nullable_Values() | |||
Assert.Equal(new Guid(GuidString), output.UniqueId); | |||
} | |||
|
|||
[Fact] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test also needs its indentation fixed.
Can you remove the last commit and submit that as a separate PR? It has nothing to do with this PR. Thanks! |
My bad...removed. |
Changed JsonDeserializer to look for and honor DeserializeAs attribute
I need to be able to map a property name on my model type to a different name in Json when deserializing. I'm reusing the DeserializeAs attribute to do this and just having the JsonDeserialize check to see if the attribute exists, and if it does prefer that name over the models property name. I added a test for this as well.