Well I have to apply a FILTER_SANITIZE_SPECIAL_CHARS
to all the fields of a json.
You currently get json like this:
// Recebo o json
$json = filter_input(INPUT_POST, 'json', FILTER_DEFAULT);
// Decodifica o Json
$obj = json_decode($json);
// Aqui eu tenho que aplicar o 'FILTER_SANITIZE_SPECIAL_CHARS'
The json var_dump:
{
"Autenticacao": {
"login": "100",
"senha": "123"
},
"operacao": {
"nome": "hugo",
"endereco": "rua sei la",
"numero": "123"
}
}
How do I navigate the login
, senha
, nome
, endereco
, and numero
fields by applying FILTER_SANITIZE_SPECIAL_CHARS
?
Edit ----------------------------
I've tried real_escape_string
as follows:
foreach ($obj as &$main) {
foreach ($main as &$value) {
$value = $conexao->real_escape_string($value);
}
}
But I'm having this error:
mysqli::real_escape_string() expects parameter 1 to be string, object given in