Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/07/2016, 23:01
Avatar de berkeleyPunk
berkeleyPunk
 
Fecha de Ingreso: febrero-2013
Ubicación: México :C
Mensajes: 565
Antigüedad: 11 años, 2 meses
Puntos: 22
Pregunta ¿Cómo iterar sobre un jSON?

Hola a todos!

Voy al grano, tengo un array llamado $resultado. Sus keys son numéricos, y los valores son jSON's. Así:
Código json:
Ver original
  1. {
  2.     "metadata.title": "",
  3.     "metadata.description": "",
  4.     "metadata.keywords": "",
  5.     "metadata.robots": "",
  6.     "metadata.author": "",
  7.     "config.enable_comments": "0",
  8.     "config.primary_category": "27"
  9. }

Necesito recuperar el valor de config.primary_category. Es decir, necesito recuperar el 27. ¿Cómo lo recupero? Intento recuperarlo así:
Código PHP:
foreach ($resultado as $key => $value) {
    if ( 
is_object($value) ) {
        echo 
$value->config.primary_category;
    }

Evidentemente no funciona, y en pantalla sólo se devuelve esto: "primary_category".

¿Me ayudan a recuperar el 27?

Saludos!