I have this JSON string
[ \"postal_code\" ]
My enum definition:
[DataContract]
public enum MyEnum
{
[EnumMember(Value = "postal_code")]
PostalCode,
}
Here's what I've done so far:
byte[] byteArray = Encoding.ASCII.GetBytes(jsonString);
MemoryStream outputStream = new MemoryStream(byteArray);
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(MyEnum[]));
MyEnum[] myEnum = (MyEnum[]) dataContractJsonSerializer.ReadObject(outputStream);
outputStream.Close();
//return myEnum ;
I get an error upon reaching the ReadObject line
System.FormatException: Input string was not in the correct format: nDigits == 0.
How can I properly deserialize the JSON string to MyEnum?
I also want to avoid using JSON.Net. I'd want to go with DataContractJsonSerializer.