public override Future WriteJson(object data, JsonWriter writer) { var po = (ParseObject)data; lock (po.property_lock) { // fold in our [ParseKey] properties if (po.property_keys != null) { foreach (var kv in po.property_keys) { object dictValue = null; po.properties.TryGetValue (kv.Key, out dictValue); var propValue = kv.Value.GetValue (data, null); if ((propValue != null && !propValue.Equals (dictValue)) || (propValue == null && dictValue != null)) { po.properties [kv.Key] = propValue; po.updated_properties.Add (kv.Key); } } } if (po.updated_properties.Count == 0) return Future.Fulfilled; writer.StartObject (); foreach (var key in po.updated_properties) { if (key == null) continue; //FIXME: this really should never happen writer.WriteKey (key); var value = po.properties [key]; if (value is DateTime) { writer.StartObject (); writer.WriteKey ("__type"); writer.WriteString ("Date"); writer.WriteKey ("iso"); writer.WriteString (ToString ((DateTime)value)); writer.EndObject (); continue; } else if (value is byte []) { throw new NotImplementedException ("Write byte [] data"); } else if (value is ParseObject) { var obj = (ParseObject)value; ParseTypeAttribute pta = null; if ((pta = (ParseTypeAttribute)obj.GetType ().GetCustomAttributes (typeof (ParseTypeAttribute), true).SingleOrDefault ()) == null || !pta.Inline) { obj.Save ().Wait (); writer.StartObject (); writer.WriteKey ("__type"); writer.WriteString ("Pointer"); writer.WriteKey ("className"); writer.WriteString (obj.pointerClassName); writer.WriteKey ("objectId"); writer.WriteString (obj.ObjectId); writer.EndObject (); continue; } } else if (value is ParseFile) { var file = (ParseFile)value; file.Save ().Wait (); writer.StartObject (); writer.WriteKey ("__type"); writer.WriteString ("File"); writer.WriteKey ("name"); writer.WriteString (file.RemoteName); writer.EndObject (); continue; } else if (value is ParseGeoPoint) { var geo = (ParseGeoPoint)value; writer.StartObject (); writer.WriteKey ("__type"); writer.WriteString ("GeoPoint"); writer.WriteKey ("latitude"); writer.WriteValue (geo.Latitude); writer.WriteKey ("longitude"); writer.WriteValue (geo.Longitude); writer.EndObject (); continue; } writer.WriteValue (value).Wait (); } writer.EndObject (); } return Future.Fulfilled; }