private static void WriteJson(IJsonWrapper obj, JsonWriter writer) { if (obj == null) { writer.Write(null); } else if (obj.IsString) { writer.Write(obj.GetString()); } else if (obj.IsBoolean) { writer.Write(obj.GetBoolean()); } else if (obj.IsReal) { writer.Write(obj.GetReal()); } else if (obj.IsNatural) { writer.Write(obj.GetNatural()); } else if (obj.IsArray) { writer.WriteArrayStart(); foreach (object elem in (IList)obj) { WriteJson((JsonData)elem, writer); } writer.WriteArrayEnd(); } else if (obj.IsObject) { writer.WriteObjectStart(); foreach (DictionaryEntry entry in ((IDictionary)obj)) { writer.WritePropertyName((string)entry.Key); WriteJson((JsonData)entry.Value, writer); } writer.WriteObjectEnd(); } }