Esempio n. 1
0
        public JsonResult getGps(int id)
        {
            var gps      = new GPS();
            var dataGps  = new jsonModel();
            var chipJson = new jsonChip();
            var gpsJson  = new jsonGps();


            gps = objGps.obtenerGps(id);


            gpsJson.idGps       = Convert.ToString(gps.idgps);
            gpsJson.idChip      = Convert.ToString(gps.idchip);
            gpsJson.modelo      = gps.modelo;
            gpsJson.estadoUso   = gps.estado_uso;
            gpsJson.garantia    = gps.garantia;
            gpsJson.fechaCompra = parseDate(Convert.ToString(gps.fecha_compra));
            gpsJson.imei        = gps.imei;

            chipJson.numero = gps.CHIP.numero;

            dataGps.jsonGps  = gpsJson;
            dataGps.jsonchip = chipJson;

            return(Json(dataGps));
        }
        static void Main(string[] args)
        {
            string json = "{" +
                          "\"@odata_context\": \"https://graph.microsoft.com/v1.0/$metadata#users\"," +
                          "\"@odata_nextLink\": \"https://graph.microsoft.com/v1.0/users?$top=999&$skiptoken=\"," +
                          "\"value\": [{" +
                          "\"businessPhones\": [999999]," +
                          "\"displayName\": \"___XXXXX_Conv_SA___\"," +
                          "\"givenName\": null," +
                          "\"jobTitle\": null," +
                          "\"mail\": null," +
                          "\"mobilePhone\": null," +
                          "\"officeLocation\": null," +
                          "\"preferredLanguage\": null," +
                          "\"surname\": null," +
                          "\"userPrincipalName\": \"[email protected]\"," +
                          "\"id\": \"e7dc80e8-482d-4020-bb81-eee9458f5a37\"" +
                          "}]" +
                          "}";
            jsonModel data = JsonConvert.DeserializeObject <jsonModel>(json);

            foreach (valueModel i in data.value.ToList())
            {
                Console.WriteLine("Complete Value object");
                Console.WriteLine("--------START---------");
                Console.WriteLine(JsonConvert.SerializeObject(i));
                Console.WriteLine("---------END----------");
                Console.WriteLine("----------------------");
                Console.WriteLine("get value by property name");
                Console.WriteLine("=> businessPhones:" + i.businessPhones[0]);
                Console.WriteLine("=> displayName:" + i.displayName);
                Console.WriteLine("=> givenName:" + i.givenName);
                Console.WriteLine("=> jobTitle:" + i.jobTitle);
                Console.WriteLine("=> mail:" + i.mail);
                Console.WriteLine("=> and so on");
            }
            Console.ReadLine();
        }