In a JSON file I'd like to decode with PHP's json_decode()
function I have items like this:
[{
"id_regione":3,
"regione":"Calabria",
"superficie":15221.9,
"num_residenti":1970521,
"num_comuni":409,
"num_provincie":5,
"presidente":"Gerardo Mario Oliverio",
"cod_istat":18,
"cod_fiscale":02205340793, /* problem here */
"piva":null,
"pec":"dipartimento.presidenza@pec.regione.calabria.it",
"sito":"www.regione.calabria.it",
"sede":"Regione Calabria / Via Massara 2, 88100 Catanzaro"
}]
You see, the part "cod_fiscale":02205340793
stops decoding with no apparent reason: but looking at PHP docs I found this in the changelog:
7.0.0 Rejected RFC 7159 incompatible number formats - top level (07, 0xff, .1, -.1) and all levels ([1.], [1.e1])
Oh, I see: 02205340793
seems an incompatible number format... Really it's not a number, it's a tax code (and I could potentially have problems also with phone numbers like 0935123456)
So, what's the best way to deal with these items? Convert everything to a string? And how?