Guest User

Untitled

a guest
Sep 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. $json = '{"foo":283675428357628352}';
  2. $obj = json_decode($json, false, JSON_BIGINT_AS_STRING);
  3. $json2 = json_encode($obj, JSON_NUMERIC_CHECK);
  4. var_dump($json === $json2); // true
  5.  
  6. $json = '{"foo":9223372036854775807}';
  7. $obj = json_decode($json);
  8. $json2 = json_encode($obj);
  9.  
  10. var_dump(PHP_INT_MAX, $obj, $json2);
  11.  
  12. int(9223372036854775807)
  13. object(stdClass)#1 (1) {
  14. ["foo"]=>
  15. int(9223372036854775807)
  16. }
  17. string(27) "{"foo":9223372036854775807}"
Add Comment
Please, Sign In to add comment