How to deserialize with RestSharp when I have an attribute named "value"?

Go To StackoverFlow.com

1

I am using RestSharp to deserialize a XML file where some of the nodes are like this:

<element value="something" />

The elementes with an attribute called 'value' will not deserialize. Any ideas on how to get RestShap to deserialize this?

The object used to deserialize is like:

public class Object
{
    public string Value { get; set; }
}

Please note, the XML is returned from a web service so I do not have the option of changing the attribute name to something different.

2012-04-04 19:30
by Kenn


1

Okay, I have found a solution. I think this is somewhat an edge case.

I renamed the variable

public string Value {get;set;}

to

public string value {get;set;}

And now it deserializes perfectly. Guess the Uppercase Value is for the value contained in a XML element only.

2012-04-05 08:45
by Kenn
Edge case indeed. I'm glad you figured it out - John Sheehan 2012-04-05 20:51
Ads