private JToken SerializeArray(object value, Metadata.TypeInfo typeInfo)
        {
            var array  = value as IEnumerable;
            var tokens = new List <JToken>();

            foreach (object arrValue in array)
            {
                JToken token = Serialize(arrValue, typeInfo.GetElementInfo());
                tokens.Add(token);
            }
            return(new JArray(tokens.ToArray()));
        }
        private object DeserializeArray(JToken jsonValue, Metadata.TypeInfo typeInfo)
        {
            var jsonArr = jsonValue as JArray;

            if (jsonArr == null)
            {
                throw new SerializationException("Array type expected");
            }
            var array = Array.CreateInstance(typeInfo.Type, jsonArr.Count);

            for (int n = 0; n < jsonArr.Count; n++)
            {
                array.SetValue(Deserialize(jsonArr[n], typeInfo.GetElementInfo()), n);
            }
            return(array);
        }