private static void WriteJson(IJsonWrapper obj, JsonWriter writer) { if (obj.IsString) { writer.Write(obj.GetString()); return; } if (obj.IsBoolean) { writer.Write(obj.GetBoolean()); return; } if (obj.IsDouble) { writer.Write(obj.GetDouble()); return; } if (obj.IsInt) { writer.Write(obj.GetInt()); return; } if (obj.IsLong) { writer.Write(obj.GetLong()); return; } if (obj.IsDecimal) { writer.Write(obj.GetDecimal()); return; } if (obj.IsULong) { writer.Write(obj.GetUlong()); return; } if (obj.IsArray) { writer.WriteArrayStart(); foreach (object elem in (IList)obj) { WriteJson((JsonData)elem, writer); } writer.WriteArrayEnd(); return; } if (obj.IsObject) { writer.WriteObjectStart(); foreach (var entry in ((IDictionary <string, JsonData>)obj)) { writer.WritePropertyName(entry.Key); WriteJson(entry.Value, writer); } writer.WriteObjectEnd(); } }