This project has moved. For the latest updates, please go here.

Can we get a JsonWriter.WriteValue(object) overload?

Aug 11, 2008 at 5:53 AM

I'm hooking up a couple of custom converters to JSON.NET and while it's easy enough to do this in some cases, it's a bit painful if you have a type that contains other types that you're explicitly iterating over. For example, I have a requirement for some legacy code to serialize DataTables and there's no way that I can see to easily get a single JSON value out of the writer of my type is of type object nad I can't call a specific overload of WriteValue.

What I'm currently doing is this:

public override void WriteJson(JsonWriter writer, object dataRow)
    JsonSerializer ser = new JsonSerializer();                       
    DataRow row = dataRow as DataRow;


    foreach (DataColumn column in row.Table.Columns)

which uses the highlevel root Serializer. Seems like there should be a lower level to do this. Is there? So far no luck <g> But certainly writer.WriteValue(object value); would be the expected method to call.

+++ Rick ---

Aug 12, 2008 at 10:12 PM
Aug 13, 2008 at 2:27 AM
Awesome James!