Exemple #1
0
 public static T Deserialize <T>(Stream input)
 {
     if (ScalarDeserializer.IsScalar(typeof(T)))
     {
         throw new System.Exception("Not supported");
     }
     return(Deserialize <T>(input, string.Empty));
 }
Exemple #2
0
 public static T DeserializeFromFile <T>(string file, string fieldPrefix)
 {
     if (ScalarDeserializer.IsScalar(typeof(T)))
     {
         throw new System.Exception("Not supported");
     }
     using (JsonReader reader = new JsonReader(new FileStream(file, FileMode.Open, FileAccess.Read)))
     {
         return(JsonDeserializer.Deserialize <T>(reader));
     }
 }
Exemple #3
0
 public static T Deserialize <T>(Stream input, string fieldPrefix)
 {
     if (ScalarDeserializer.IsScalar(typeof(T)))
     {
         throw new System.Exception("Not supported");
     }
     using (JsonReader reader = new JsonReader(input))
     {
         return(JsonDeserializer.Deserialize <T>(reader));
     }
 }
Exemple #4
0
        public static T Deserialize <T>(string json, string fieldPrefix)
        {
            if (ScalarDeserializer.IsScalar(typeof(T)))
            {
                return(ScalarDeserializer.Deserialize <T>(json));
            }

            using (StringReader sr = new StringReader(json))
            {
                using (JsonReader reader = new JsonReader(sr))
                {
                    return(JsonDeserializer.Deserialize <T>(reader, fieldPrefix));
                }
            }
        }
Exemple #5
0
        public static object Deserialize(string json, System.Type type)
        {
            if (ScalarDeserializer.IsScalar(type))
            {
                return(ScalarDeserializer.Deserialize(json, type));
            }

            using (StringReader sr = new StringReader(json))
            {
                using (JsonReader reader = new JsonReader(sr))
                {
                    return(JsonDeserializer.Deserialize(reader, type));
                }
            }
        }