private void WriteJsonProperty(string propertyName, object json) { if (json != null) { string jsonString = null; using (var writer = new TextJsonWriter()) { JsonSerializer.Write(json, writer); if (!writer.IsEmpty) { jsonString = writer.ToString(); } } if (!string.IsNullOrWhiteSpace(jsonString)) { if (_commaNeeded) { WriteComma(); } WritePropertyName(propertyName); WriteJsonString(jsonString); _commaNeeded = true; } } }
private void WriteJson(object json) { using (var writer = new TextJsonWriter()) { JsonSerializer.Write(json, writer); WriteJsonString(writer.ToString()); } }
/// <summary> /// Serializes the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">value</exception> public static string Serialize(T value) { if (value == null) { throw new ArgumentNullException("value"); } using (var writer = new TextJsonWriter()) { Write(value, writer); return(writer.ToString()); } }