/// <inheritdoc /> protected override ClarifaiOutput <T> Unmarshaller(dynamic jsonObject) { if (jsonObject.outputs != null && jsonObject.outputs.Count == 1) { var jsonOutput = jsonObject.outputs[0]; return(ClarifaiOutput <T> .Deserialize(jsonOutput)); } throw new ClarifaiException("A single output is not present in the API"); }
/// <inheritdoc /> protected override ClarifaiOutput <T> Unmarshaller(dynamic jsonObject) { if (jsonObject.outputs != null && jsonObject.outputs.Count == 1) { var jsonOutput = jsonObject.outputs[0]; return(ClarifaiOutput <T> .Deserialize(HttpClient, jsonOutput)); } throw new ClarifaiException("The response does not contain exactly one output."); }
/// <inheritdoc /> protected override List <ClarifaiOutput <T> > Unmarshaller(dynamic jsonObject) { var outputs = new List <ClarifaiOutput <T> >(); foreach (var jsonOutput in jsonObject.outputs) { outputs.Add(ClarifaiOutput <T> .Deserialize(HttpClient, jsonOutput)); } return(outputs); }
/// <summary> /// Deserializes the object out of a JSON dynamic object. /// </summary> /// <param name="httpClient">the HTTP client</param> /// <param name="jsonObject">the JSON object</param> /// <returns>the deserialized object</returns> public static WorkflowResult Deserialize(IClarifaiHttpClient httpClient, dynamic jsonObject) { var status = ClarifaiStatus.Deserialize(jsonObject.status); var input = ClarifaiInput.Deserialize(jsonObject.input); var predictions = new List <ClarifaiOutput>(); foreach (dynamic output in jsonObject.outputs) { dynamic model = output.model; ModelType modelType = ModelType.DetermineModelType( (string)model.output_info.type_ext); predictions.Add(ClarifaiOutput.Deserialize(httpClient, modelType, output)); } return(new WorkflowResult(status, input, predictions)); }