views:

11

answers:

0

Can anyone serialize a Queue using the DataContractJsonSerializer in Silverlight 4.0 ? Here is some example code that throws. If not what additional collections can not be serialized using the Json Serializer ?

    public String Serialize()
    {
        String jsonString = String.Empty;
        using (MemoryStream s = new MemoryStream())
        {
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Queue<String>));
            serializer.WriteObject(s, new Queue<String>());
            s.Position = 0;
            StreamReader sr = new StreamReader(s);
            jsonString = sr.ReadToEnd();
        }

        return jsonString;
    }