JsonTextWriter.WriteProperty

Apr 22, 2011 at 1:24 AM

Hello,

I found several nice samples on the net that referred to a method called

JsonTextWriter.WriteProperty

but there isn't one in the latest distro so I've added the following to my build:

 /// <summary>
 /// Writes the property name/value pair on a Json object.

/// </summary>
/// <param name="name">The name of the property.</param>
/// <param name="value">The value of the property.</param>
public void WriteProperty(string name, object value)
{
      base.WritePropertyName(name);
      JavaScriptUtils.WriteEscapedJavaScriptString(_writer, name, _quoteChar, _quoteName);
      _writer.Write(':');
      WriteValue(value);
}

It seems to do the job very well and makes the app code much more terse.