示例#1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            JsonObjectBase obj = value as JsonObjectBase;

            if (obj?.JObject == null)
            {
                writer.WriteNull();
                return;
            }

            obj.JObject.WriteTo(writer);
        }
示例#2
0
        private object DeserializeListItem(PdListBase pd, JsonObjectBase jsonData)
        {
            object item = null;

            if (jsonData is JsonObjectSimple)
            {
                var jsonSimple = jsonData as JsonObjectSimple;

                if (jsonSimple.Value != null)
                {
                    item = pd.ItemFabric.StringToObject(jsonSimple.Value);
                }
            }
            else

            if (jsonData is JsonObjectClass)
            {
                var jsonClass = jsonData as JsonObjectClass;
                item = pd.ItemFabric.CreateInstance();
                Deserialize(item, jsonClass.Class);
            }

            return(item);
        }
 public static string ToJson(this JsonObjectBase self) => JsonConvert.SerializeObject(self, Settings);
示例#4
0
 public static string Serialize <T>(this JsonObjectBase <T> obj)
 {
     return(JsonConvert.SerializeObject(obj, _jsonSerializerSettings));
 }