/// <summary> /// Read the JSON object and convert to the object. This will allow the serializer to /// automatically convert the object. No special instructions need to be done and all /// the properties found in the JSON string need to be used. /// /// DataSet.Adcp2InfoDataSet decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject{DataSet.Adcp2InfoDataSet}(encodedEns) /// /// </summary> /// <param name="reader">NOT USED. JSON reader.</param> /// <param name="objectType">NOT USED> Type of object.</param> /// <param name="existingValue">NOT USED.</param> /// <param name="serializer">Serialize the object.</param> /// <returns>Serialized object.</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.Null) { // Load the object JObject jsonObject = JObject.Load(reader); // Decode the data int NumElements = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMELEMENTS]; int ElementsMultiplier = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ELEMENTSMULTIPLIER]; // Create the object var data = new Adcp2InfoDataSet(DataSet.Ensemble.DATATYPE_FLOAT, NumElements, ElementsMultiplier, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.Adcp2InfoID); // ViPwr data.ViPwr = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VIPWR]; // ViNf data.ViNf = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VINF]; // ViNfl data.ViNfl = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VINFL]; // ViSleep data.ViSleep = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VISLEEP]; return(data); } return(null); }
/// <summary> /// Read the JSON object and convert to the object. This will allow the serializer to /// automatically convert the object. No special instructions need to be done and all /// the properties found in the JSON string need to be used. /// /// DataSet.Adcp2InfoDataSet decodedEns = Newtonsoft.Json.JsonConvert.DeserializeObject{DataSet.Adcp2InfoDataSet}(encodedEns) /// /// </summary> /// <param name="reader">NOT USED. JSON reader.</param> /// <param name="objectType">NOT USED> Type of object.</param> /// <param name="existingValue">NOT USED.</param> /// <param name="serializer">Serialize the object.</param> /// <returns>Serialized object.</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType != JsonToken.Null) { // Load the object JObject jsonObject = JObject.Load(reader); // Decode the data int NumElements = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_NUMELEMENTS]; int ElementsMultiplier = (int)jsonObject[DataSet.BaseDataSet.JSON_STR_ELEMENTSMULTIPLIER]; // Create the object var data = new Adcp2InfoDataSet(DataSet.Ensemble.DATATYPE_FLOAT, NumElements, ElementsMultiplier, DataSet.Ensemble.DEFAULT_IMAG, DataSet.Ensemble.DEFAULT_NAME_LENGTH, DataSet.Ensemble.Adcp2InfoID); // ViPwr data.ViPwr = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VIPWR]; // ViNf data.ViNf = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VINF]; // ViNfl data.ViNfl = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VINFL]; // ViSleep data.ViSleep = (float)jsonObject[DataSet.BaseDataSet.JSON_STR_ADCP2INFO_VISLEEP]; return data; } return null; }