fork download
  1. <?php
  2.  
  3. $obj = json_decode('{
  4. "Autenticacao": {
  5. "login": 100000000000,
  6. "senha": "123"
  7. },
  8. "operacao": {
  9. "nome": false,
  10. "endereco": "rua sei la",
  11. "numero": "123"
  12. }
  13. }');
  14.  
  15. foreach ($obj as &$main) {
  16. foreach ($main as &$value) {
  17. $value = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
  18. }
  19. }
  20.  
  21. var_dump($obj);
  22.  
Success #stdin #stdout 0s 82880KB
stdin
Standard input is empty
stdout
object(stdClass)#2 (2) {
  ["Autenticacao"]=>
  object(stdClass)#1 (2) {
    ["login"]=>
    string(12) "100000000000"
    ["senha"]=>
    string(3) "123"
  }
  ["operacao"]=>
  &object(stdClass)#3 (3) {
    ["nome"]=>
    string(0) ""
    ["endereco"]=>
    string(10) "rua sei la"
    ["numero"]=>
    &string(3) "123"
  }
}