Various 3rd party companies are forcing us to use non-conventional code and produce non-standard output.
We are using standard json_encode()
to output a JSON variable in JS/HTML which looks like:
"custom":{"1":2,"2":7,"3":5}
Now they tell us this isn't working for them, they need it this way:
"custom":{"1":"2","2":"7","3":"5"}
Can I force PHP to wrap quotes arround numbers? Maybe using cast (string)
when we build the object before encoding?
Mainly, we need an opposite of the following option bitflag:
JSON_NUMERIC_CHECK (integer)
Encodes numeric strings as numbers. Available since PHP 5.3.3.
But I doubt this exists.