[Mono-dev] JSON Deserialization

Antoine Cailliau antoinecailliau at gmail.com
Sun Apr 24 10:53:37 EDT 2011

Hi folks,

I'm trying to convert a JSON list to an IEnumerable list.

This piece of code fails to work on Mono. It should be working with ms
framework. Can someone test it for me ? I don't have the framework on
my computer.

	class Element {
		public string Name { get; set; }
	class MainClass
		public static void Main (string[] args)
			MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes
("[{Name:'1'}, {Name:'2'}]"));
			DataContractJsonSerializer serializer = new
			IEnumerable<Element> list = serializer.ReadObject(ms) as
			Console.WriteLine (list.Count() == 2);

The raised exception is

	Unhandled Exception:
System.Runtime.Serialization.SerializationException: Deserialization
has failed ---> System.Xml.XmlException: Unexpected token: '

If someone have an idea on how to fix it :-)


More information about the Mono-devel-list mailing list