With json_encode, is there a way to force certain values not to be converted into numeric? With json_encode, is there a way to force certain values not to be converted into numeric? json json

With json_encode, is there a way to force certain values not to be converted into numeric?


Instead of using strval() on the fields that should stay strings, use intval() or floatval() on fields that should be numeric. In other words, give the JSON encoder the correct types. Then, you don't need JSON_NUMERIC_CHECK to fix up things that should have been numbers to start with.