Exemplo n.º 1
0
        public Sensor(string json)
        {
            JObject jSensor = JObject.Parse(json);

            //JToken jSensor = jObject[""]; //aqui deberia ir sensor? pero en el JSON ex no se lo encuentra en el inicio
            this.Id   = Convert.ToInt16(jSensor["id"]); //max id 32767;
            this.Tipo = jSensor["sensors"].ToArray();
            int nValores = this.Tipo.Length;

            this.Valor = new List <double>();

            /*foreach (string tipoSensor in this.Tipo)
             * {
             *  this.Valor.Add(Convert.ToDouble(jSensor[tipoSensor]));
             * }*/
            for (int i = 0; i < nValores; i++)
            {
                this.Valor.Add(Convert.ToDouble(jSensor[Tipo.GetValue(i).ToString()]));
            }
        }