json_decode/encode true/false

Does this ( http://php.net/manual/en/migration56.incompatible.php#migration56.incompatible.json-decode ) mean that there is no longer possible to use json_encode(false) ?

You missed this?

Migrating from PHP 5.5.x to PHP 5.6.x


json_decode() strictness ¶

json_decode() now rejects non-lowercase variants of the JSON literals true, false and null at all times, as per the JSON specification, and sets json_last_error() accordingly. Previously, inputs to json_decode() that consisted solely of one of these values in upper or mixed case were accepted.

This change will only affect cases where invalid JSON was being passed to json_decode(): valid JSON input is unaffected and will continue to be parsed normally.

Actually I did read that before the link I gave above! but I still have difficulty to understand what exactly it means! please clarify with example.

Sorry, I’m confused.

An example of how different PHP versions deal with json_decode and how it might affect json_encode ?

What part are you having trouble with?

please just explain what that statement on manual mean with example!

Just that

There is NO example to your question as you’ve asked it.

Can’t you just explain/clarify what that statement mean?

Sorry, but it seems you are asking for me to do your thinking.
I have enough trouble doing my own.

You are asking the wrong question.

Let’s say you have the following json

  my_value: FALSE

json_decode will now fail, because FALSE isn’t all lowercase. If its value was FaLsE, it would fails as well. It will only succeed if the value is false

1 Like

Thanks for explanation.

To be more precise - PHP now correctly recognizes that the above is NOT JSON, as it does not comply with the JSON specification.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.