Foros del Web » Programando para Internet » PHP »

archivo json

Estas en el tema de archivo json en el foro de PHP en Foros del Web. hola. yo no se mucho de json , pero es posible con este trozo de datos determinar como extraer estos valores uno a uno para ...
  #1 (permalink)  
Antiguo 10/04/2017, 08:49
Avatar de mveraa  
Fecha de Ingreso: diciembre-2002
Ubicación: santiago-chilito
Mensajes: 1.931
Antigüedad: 21 años, 10 meses
Puntos: 2
archivo json

hola. yo no se mucho de json , pero es posible con este trozo de datos determinar como extraer estos valores uno a uno para guardarlo en una bd.


[{"id":"14176187542","reportDate":"2017-04-10T11:04:03-03:00","inputDate":"2017-04-10T11:04:03-03:00","device_id":65670,"holder_id":63635,"holder _domain":"DDCY12","holder_name":"80","event_id":2, "event_desc":"Reporte por tiempo","validity":12,"dop":1.0,"latitude":-33.440756,"longitude":-70.636262,"location":"Baron Pierre De Coubertin 86, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.1,"course":71,"alt itude":566.4,"odometer":147390.2,"cartographyLimit Speed":40.0,"gpsSpeed":0.1,"ignition":1,"ignitionD ate":"2017-04-10T11:00:02-03:00","FALLA":0}, {"id":"14176150646","reportDate":"2017-04-10T11:00:29-03:00","inputDate":"2017-04-10T11:00:32-03:00","device_id":81460,"holder_id":78833,"holder _domain":"GSBY37","holder_name":"A-15","event_id":2,"event_desc":"Reporte por tiempo","validity":12,"dop":1.0,"latitude":-33.442634,"longitude":-70.665885,"location":"Agustinas 2141, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.0,"course":119,"al titude":559.3,"odometer":121853.4,"cartographyLimi tSpeed":40.0,"gpsSpeed":0.0,"ignition":0,"ignition Date":"2017-04-07T18:52:50-03:00"}, {"id":"14105204741","reportDate":"2017-04-03T18:39:02-03:00","inputDate":"2017-04-03T18:46:31-03:00","device_id":40882,"holder_id":63696,"holder _domain":"NH2438","holder_name":"141","event_id":2 06,"event_desc":"Batería baja","validity":12,"dop":0.0,"latitude":-33.468161,"longitude":-70.628884,"location":"Padre Orellana 1900, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.3,"course":349,"al titude":525.4,"cartographyLimitSpeed":40.0,"gpsSpe ed":0.3,"ignition":0,"ignitionDate":"2017-04-03T11:45:27-03:00"}, {"id":"13965103516","reportDate":"2017-03-21T21:05:14-03:00","inputDate":"2017-03-21T21:05:11-03:00","device_id":65762,"holder_id":62621,"holder _domain":"MY7474","holder_name":"242","event_id":2 ,"event_desc":"Reporte por tiempo","validity":12,"satellites":9,"dop":1.0,"la titude":-33.468782,"longitude":-70.628324,"location":"General Gana 206, Santiago Central,Santiago,Chile ","speed":0.0,"course":32,"altitude":492.7,"odomet er":268839.4,"gpsSpeed":0.0,"cartographyLimitSpeed ":40.0,"ignition":1,"ignitionDate":"2017-03-20T11:57:08-03:00"},





muchas gracias.
__________________
"Cuando se adelanta un oponente, enfréntalo y salúdalo; si intenta retroceder, déjalo seguir su camino"
  #2 (permalink)  
Antiguo 10/04/2017, 09:46
 
Fecha de Ingreso: octubre-2010
Ubicación: España
Mensajes: 1.007
Antigüedad: 14 años, 1 mes
Puntos: 123
Respuesta: archivo json

Si es posible. Pero se agradecería que hubieses sangrado los datos para una lectura más legible.
__________________
Unset($vida['malRollo']);
  #3 (permalink)  
Antiguo 10/04/2017, 10:01
Avatar de mveraa  
Fecha de Ingreso: diciembre-2002
Ubicación: santiago-chilito
Mensajes: 1.931
Antigüedad: 21 años, 10 meses
Puntos: 2
Respuesta: archivo json

muchas gracias, mejora ahi.

HTTP/1.1 200 OK Server: nginx/1.1.19 Date: Mon, 10 Apr 2017 15:08:25 GMT Content-Type: application/json;charset="UTF-8" Content-Length: 84828 Connection: close Vary: Accept-Encoding
[{"id":"14176599864","reportDate":"2017-04-10T11:43:37-03:00","inputDate":"2017-04-10T11:43:38-03:00","device_id":65670,"holder_id":63635,"holder _domain":"DDCY12","holder_name":"80","event_id":2, "event_desc":"Reporte por tiempo","validity":12,"dop":1.0,"latitude":-33.432917,"longitude":-70.653421,"location":"Presidente Balmaceda 1154, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.1,"course":279,"al titude":554.6,"odometer":147393.8,"cartographyLimi tSpeed":80.0,"gpsSpeed":0.1,"ignition":0,"ignition Date":"2017-04-10T11:43:34-03:00","FALLA":0},

{"id":"14176774089","reportDate":"2017-04-10T12:00:22-03:00","inputDate":"2017-04-10T12:00:25-03:00","device_id":81460,"holder_id":78833,"holder _domain":"GSBY37","holder_name":"A-15","event_id":2,"event_desc":"Reporte por tiempo","validity":12,"dop":1.0,"latitude":-33.442634,"longitude":-70.665885,"location":"Agustinas 2141, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.0,"course":119,"al titude":559.3,"odometer":121853.4,"cartographyLimi tSpeed":40.0,"gpsSpeed":0.0,"ignition":0,"ignition Date":"2017-04-07T18:52:50-03:00"},

{"id":"14105204741","reportDate":"2017-04-03T18:39:02-03:00","inputDate":"2017-04-03T18:46:31-03:00","device_id":40882,"holder_id":63696,"holder _domain":"NH2438","holder_name":"141","event_id":2 06,"event_desc":"Batería baja","validity":12,"dop":0.0,"latitude":-33.468161,"longitude":-70.628884,"location":"Padre Orellana 1900, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.3,"course":349,"al titude":525.4,"cartographyLimitSpeed":40.0,"gpsSpe ed":0.3,"ignition":0,"ignitionDate":"2017-04-03T11:45:27-03:00"},
__________________
"Cuando se adelanta un oponente, enfréntalo y salúdalo; si intenta retroceder, déjalo seguir su camino"
  #4 (permalink)  
Antiguo 11/04/2017, 07:42
 
Fecha de Ingreso: enero-2011
Ubicación: /root
Mensajes: 530
Antigüedad: 13 años, 10 meses
Puntos: 61
Respuesta: archivo json

Quizas de esta forma te sea mas facil guardarlo:

Código PHP:
Ver original
  1. $json = '{"id":"14176774089","reportDate":"2017-04-10T12:00:22-03:00","inputDate":"2017-04-10T12:00:25-03:00","device_id":81460,"holder_id":78833,"holder _domain":"GSBY37","holder_name":"A-15","event_id":2,"event_desc":"Reporte por tiempo","validity":12,"dop":1.0,"latitude":-33.442634,"longitude":-70.665885,"location":"Agustinas 2141, Santiago Central,Santiago,Chile ","area_type":"urban","speed":0.0,"course":119,"al titude":559.3,"odometer":121853.4,"cartographyLimi tSpeed":40.0,"gpsSpeed":0.0,"ignition":0,"ignition Date":"2017-04-07T18:52:50-03:00"}';
  2.  
  3.  
  4. $obj = json_decode($json);
  5.  
  6.  
  7.  
  8.  
  9. echo $obj->reportDate;

Saludos

Etiquetas: bd, json
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:06.