Serialize DataSet

Jan 4, 2010 at 6:24 PM

Hi James,

Is there a way to control the serialization of a datatable within a dataset so that it creates a table object with a schema object and a rows object instead of just repeating the column names for every row?

One of the reasons i converted from xml to json was due to the verbose output of the begin/end tags and i ended up writting a small method to convert datasets to json by creating a simple object with schema (column,type) object, and rows object.  Is there a way for me to do this with JSON.NET.

 

{
    "TABLES": {
        "TABLEABC": {
            "SCHEMA": {
                "COLUMNNAMES": [
                    "COL1",
                    "COL2",
                    "COL3"
                ],
                "COLUMNTYPES": [
                    "INT",
                    "STRING",
                    "DOUBLE"
                ]
            },
            "DATA": [
                [
                    "VAL1",
                    "VAL2",
                    "VAL3"
                ],
                [
                    "VAL1",
                    "VAL2",
                    "VAL3"
                ]
            ]
        }
,
       "TABLEXYZ": {
            "SCHEMA": {
                "COLUMNNAMES": [
                    "COL1",
                    "COL2",
                    "COL3"
                ],
                "COLUMNTYPES": [
                    "INT",
                    "STRING",
                    "DOUBLE"
                ]
            },
            "DATA": [
                [
                    "VAL1",
                    "VAL2",
                    "VAL3"
                ],
                [
                    "VAL1",
                    "VAL2",
                    "VAL3"
                ]
            ]
        }
    }
}
Coordinator
Jan 6, 2010 at 1:14 AM

No but you can easily create your own dataset converter. Browse to the DataSetConverter/DataTableConverter found in the source code and start with that as a base. If you do it would be really good if you could post it here. I'd be interested in taking it and making it available to other people.