public void WriteProperty(string name, IJsonSerializable value)
 {
     if (value != null)
     {
         value.Serialize(this);
     }
 }
    public static Dictionary <string, object> ToJson(this IJsonSerializable serializable)
    {
        var json = new Dictionary <string, object>();

        serializable.Serialize(json);
        return(json);
    }
 public void WriteProperty(string name, IJsonSerializable value)
 {
     if (!this.IsNullOrEmpty(value))
     {
         this.WritePropertyName(name);
         value.Serialize(this);
     }
 }
Beispiel #4
0
 protected bool IsNullOrEmpty(IJsonSerializable instance)
 {
     if (instance != null)
     {
         emptyObjectDetector.IsEmpty = true;
         instance.Serialize(emptyObjectDetector);
         return(emptyObjectDetector.IsEmpty);
     }
     return(true);
 }
 public void WriteProperty(string name, IJsonSerializable value)
 {
     if (value != null)
     {
         value.Serialize(this);
     }
 }
 protected bool IsNullOrEmpty(IJsonSerializable instance)
 {
     if (instance != null)
     {
         this.emptyObjectDetector.IsEmpty = true;
         instance.Serialize(this.emptyObjectDetector);
         return this.emptyObjectDetector.IsEmpty;
     }
     else
     {
         return true;
     }
 }
 public void WriteProperty(string name, IJsonSerializable value)
 {
     if (!this.IsNullOrEmpty(value))
     {
         this.WritePropertyName(name);
         value.Serialize(this);
     }
 }
Beispiel #8
0
 public void WriteValue(IJsonSerializable value)
 {
     if (value == null)
     {
         WriteCore("null", /* quotes */ false);
     }
     else
     {
         WriteCore(value.Serialize(this.minimizeWhitespace), /* quotes */ false);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Write an object to JSON.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="value"></param>
        /// <param name="serializer"></param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            IJsonSerializable jsonSerializable = value as IJsonSerializable;

            jsonSerializable.Serialize(writer, serializer);
        }
Beispiel #10
0
        public static void Save(this IJsonSerializable serializable, string path)
        {
            JObject obj = serializable.Serialize();

            TextIO.Save(path, obj.ToString());
        }
Beispiel #11
0
 public void WriteProperty(string name, IJsonSerializable value)
 {
     value?.Serialize(this);
 }