0
Good I have to apply one FILTER_SANITIZE_SPECIAL_CHARS
on dodos the fields of a json.
Currently receives 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 to navigate the fields login
,senha
,nome
,endereco
and numero
applying the FILTER_SANITIZE_SPECIAL_CHARS
?
Edith ----------------------------
I tried with the real_escape_string
as follows:
foreach ($obj as &$main) {
foreach ($main as &$value) {
$value = $conexao->real_escape_string($value);
}
}
But I’m having this mistake:
mysqli::real_escape_string() expects parameter 1 to be string, object given in
as it is for all fields apply a double foreach , and then filter the strings
– 13dev
tas to pass an object as parameter
– 13dev
@13dev I understand, I have to navigate inside the object to apply the
real_escape_string
, right?– Hugo Borges
yes of course tries to do
print_r()
in the$value
to access correctly.– 13dev