Search code examples
c#azuredatatableazure-machine-learning-service

Convert a datatable string from Azure ML WS to an actual Datatable C# Object?


Basically I'm receiving an output like this from my azure ws output:

{
    'Results': {
        'WSOutput': {
            'type': 'table',
            'value': {
                'ColumnNames': ['ID', 'Start', 'Ask', 'Not', 'Passed', 'Suggest'],
                'ColumnTypes': ['Int32', 'Int32', 'Int32', 'Double', 'Int64', 'Int32'],
                'Values': [['13256025', '25000', '19000', '0.35', '1', '25000']]
            }
        }
    }
}

The string, as you can see, has the info to create a datatable object. Now, I can't seem to find an easy way to cast it to an actual datatable POCO. I'm able to manually code a parser with Newtonsoft.Json.Linq but there has to be an easier way.

Does anybody know how? I can't seem to find anything on the net.


Solution

  • Yes, there is a open source online gernator on the net (http://jsonutils.com/). Copy paste your result will give you that:

     public class Value
        {
            public IList<string> ColumnNames { get; set; }
            public IList<string> ColumnTypes { get; set; }
            public IList<IList<string>> Values { get; set; }
        }
    
        public class WSOutput
        {
            public string type { get; set; }
            public Value value { get; set; }
        }
    
        public class Results
        {
            public WSOutput WSOutput { get; set; }
        }
    
        public class Example
        {
            public Results Results { get; set; }
        }