Our PHP API outputs results using json_encode with JSON_NUMERIC_CHECK enabled, which is important for financial figures, binary values etc.. but we have recently introduced a phone number field, and it is removing zeros from the beginning of the number when it casts it as an integer.
I've tried to force "(string)" type on the value before it goes to json_encode, but it looks like the function is overriding it. eg:
$output = array(
'is_bool' => 1,
'total_amount' => '431.65',
'phone_number' => (string) '0272561313'
);
echo json_encode($output,JSON_NUMERIC_CHECK);
Produces:
{"is_bool":1,"total_amount":431.65,"phone_number":272561313}
Any suggestions on how to best handle this would be much appreciated. I really don't want to have to resort to adding trailing spaces at the end of the phone number when it's output just to get it through as a string.
Thanks!