Skip to content
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

Merged
merged 3 commits into from
Sep 4, 2013

Conversation

devinrader
Copy link
Contributor

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.

@@ -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;
Copy link
Contributor

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.

@haacked
Copy link
Contributor

haacked commented Aug 30, 2013

Looks good! Just a couple minor tweaks suggested.

@devinrader
Copy link
Contributor Author

Tweaked based on feedback.

@@ -192,6 +192,18 @@ public void Can_Deserialize_Elements_to_Nullable_Values()
Assert.Equal(new Guid(GuidString), output.UniqueId);
}

[Fact]
Copy link
Contributor

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.

@haacked
Copy link
Contributor

haacked commented Sep 4, 2013

Can you remove the last commit and submit that as a separate PR? It has nothing to do with this PR. Thanks!

@devinrader
Copy link
Contributor Author

My bad...removed.

@devinrader devinrader closed this Sep 4, 2013
@devinrader devinrader reopened this Sep 4, 2013
haacked added a commit that referenced this pull request Sep 4, 2013
Changed JsonDeserializer to look for and honor DeserializeAs attribute
@haacked haacked merged commit b60f2dd into restsharp:master Sep 4, 2013
@haacked
Copy link
Contributor

haacked commented Sep 4, 2013

Thanks for your contribution and for bearing with me! 👍
bill-murray-animated-suntory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants