Avatar of Eduardo Fuerte
Eduardo Fuerte
Flag for Brazil asked on

Could you suggest the beter way to convert this json structure to a PHP array?

Hi Experts!

Could you suggest the beter way to convert this json structure to a PHP array?

Sample: 
{
  "numeroGuia": "sample string 1",
  "paciente": {
    "nome": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      "cidade": "sample string 6"
    },
    "dataNascimento": "2018-10-22T17:53:58.4603585-03:00",
    "cpf": "sample string 2",
    "telefone": "sample string 3",
    "email": "sample string 4",
    "sexo": "sample string 5",
    "peso": 1.1,
    "convenio": 1,
    "plano": "sample string 6",
    "matricula": "sample string 7"
  },
  "contratante": {
    "tipo": 64,
    "contrato": 1
  },
  "atendimento": {
    "diagnostico": "sample string 1",
    "recurso": "sample string 2",
    "exames": "sample string 3",
    "carater": 64,
    "motivoAtendimento": "sample string 4",
    "cid": "sample string 5",
    "produto": "sample string 6"
  },
  "captacao": {
    "cor": "sample string 1",
    "dataInicio": "2018-10-22T17:53:58.4759589-03:00",
    "dataFim": "2018-10-22T17:53:58.4759589-03:00"
  },
  "origem": {
    "dataAgendadaChegadaOrigem": "2018-10-22T17:53:58.4759589-03:00",
    "nomeLocal": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      "cidade": "sample string 6"
    },
    "telefone": "sample string 2",
    "responsavel": "sample string 3"
  },
  "destino": {
    "dataAgendadaChegadaDestino": "2018-10-22T17:53:58.4759589-03:00",
    "nomeLocal": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      "cidade": "sample string 6"
    },
    "telefone": "sample string 2",
    "responsavel": "sample string 3"
  }
}

Open in new window


Thanks in advance!
PHPJSONMySQL Server

Avatar of undefined
Last Comment
Eduardo Fuerte

8/22/2022 - Mon
David Favor

Unsure exactly what you're asking.

Expand your question to clarify the exact, current problem you're having with your current JSON structure.

You have many nested structures, so likely best to keep this JSON, rather than trying to flatten your data into a simple array.
ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Eduardo Fuerte

ASKER
Hi Julian

better how?

Maybe it's the only way available...

Thanks for help!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck