I have a Java application:
Gson gson = new Gson();
String json = gson.toJson(pedido);
DataServiceGenerator dataServiceGenerator = new DataServiceGenerator();
Webservice service = dataServiceGenerator.createService(Webservice.class);
Call<String> call = service.postJson(json);
Retrofit:
@POST("/servidor.php")
Call<String> postJson(@Body String pedido);
How can I retrieve this data to save to a table in php:
[{
"ped_data_hora": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_hor_ent_producao": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_hor_retorno": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_hor_sai_producao": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_hor_saida": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_programado": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"ped_repique": {
"year": 2018,
"month": 6,
"dayOfMonth": 4,
"hourOfDay": 23,
"minute": 47,
"second": 51
},
"campo1": 1,
"campo2": 2,
"campo3": 3,
"campo4": 4
}]
I've tried this:
$resultado=json_decode(json_encode( $_POST ), true );
... $resultado->ped_data_hora;
... $resultado[0]->ped_data_hora;
... $resultado['campo1'];
So:
$resultado=json_decode($_POST);
I have already checked and my JSON is valid, I just can not get the values;