Recently I was investigating Azure Machine learning (ML) and tinkering with some code based on the Microsoft Request-Response Service example .
The following is an example of the JSON returned from the Azure ML Request-Response Service (RRS) I was working with:
{“Results”:{“Profit Prediction”:{“type”:”table”,”value”:{“ColumnNames”:[“Scored Labels”],”ColumnTypes”:[“Double”],”Values”:[[“8614.8388671875”]]}}}}
I thought this was great, generated a new class from a paste special with the JSON returned from Azure ML, added the Newton JSON package, attempted to deserialise than…
I discovered a frustrating error:
Only part of the JSON string returned deserialized into an object.
To cut a long story short, I found the cause of the error was that the PropertyName had been set in Azure ML had a space in the name. This in turn broke the JSON mapping between the response and the generated class. Therefore, the solution was to decorate the ProfitPrediction property with a JsonProperty PropertyName attribute.
[JsonProperty(PropertyName = “Profit Prediction”)]
public ProfitPrediction ProfitPrediction { get; set; }
Adding this attribute has solved the issue, completely. Did this blog save you much heartache? Have a comment, feedback or question? Feel free to tweet me @ChrisBriggsy.