JsonValue - create enums from string

Dec 12, 2011 at 7:42 PM

Hi,

I am parsing some Json that I retrieve using HttpClient, and turning it into a strongly-typed object using JsonValue.ReadAsType<T>.

The type I am creating has some properties which I would like to be Enums, but the Json I am receiving contains the names of the enum value, rather than the int value.

When I try to create the object using this, I get a parsing error but if I make the property a string, then it's fine.

Is there a way to support parsing Json using JsonValue so that the string values are converted to the right enum value?

Hope that makes sense!

Thanks,

Miles