Я имею дело с проблемой при попытке преобразовать массив php в json Это мой массив:
$datos = array(
'clave' => params_get('clave'),
'fecha' => params_get("fecha"),
'emisor' => array(
'tipoIdentificacion' => params_get("emi_tipoIdentificacion"),
'numeroIdentificacion' => params_get("emi_numeroIdentificacion")
),
'receptor' => array(
'tipoIdentificacion' => params_get("recp_tipoIdentificacion"),
'numeroIdentificacion' => params_get("recp_numeroIdentificacion")
),
'comprobanteXml' => params_get("comprobanteXml")
);
После этого я использую json_encode для создания json
$mensaje = json_encode($datos);
Но я получаю неправильный ответ
{
"resp": "{\"clave\":\"50629091800\",\"fecha\":\"2018-09-29T17:23:57-06:00\",\"emisor\":{\"tipoIdentificacion\":\"01\",\"numeroIdentificacion\":\"310\"},\"receptor\":{\"tipoIdentificacion\":\"01\",\"numeroIdentificacion\":\"11\"},\"comprobanteXml\":\"PD94b\"}"
}
И я ожидаю чего-то подобного
{
"resp": {
"clave ": "50629091800 ",
"fecha ": "2018 - 09 - 29 T17: 23: 57 - 06: 00 ",
"emisor ": {
"tipoIdentificacion ": "01",
"numeroIdentificacion ": "310"
},
"receptor": {
"tipoIdentificacion": "01",
"numeroIdentificacion ": "11"
},
"comprobanteXml ": "PD94b"
}
}
Любая помощь будет оценена