Created
July 12, 2012 22:47
-
-
Save ferventcoder/3101576 to your computer and use it in GitHub Desktop.
RestSharp Issue - Response With Different Named Types - How do you set this up?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"votePerOption":[{"Option1Votes":0},{"Option2Votes":1},{"Option3Votes":2},{"Option4Votes":1}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"votePerOption":[{"Option1Votes":0,"Option2Votes":null,"Option3Votes":null,"Option4Votes":null},{"Option1Votes":0,"Option2Votes":1,"Option3Votes":null,"Option4Votes":null},{"Option1Votes":0,"Option2Votes":null,"Option3Votes":2,"Option4Votes":null},{"Option1Votes":0,"Option2Votes":null,"Option3Votes":null,"Option4Votes":1}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VoteResults | |
{ | |
public List<VotePerOption> votePerOption { get; set; } | |
} | |
public class VotePerOption | |
{ | |
public int Option1Votes { get; set; } | |
public int? Option2Votes { get; set; } | |
public int? Option3Votes { get; set; } | |
public int? Option4Votes { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client.AddHandler("application/vnd.javascript", new JsonDeserializer()); |
The fix is to do some post processing after the results come back...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this instead: