I have an array of JSON data that i'd like to import. An example of what i'd call non-problematic JSON data would be:
[{
"records": [{
"timestamp": 1437805800,
"Import": 1011546
},{
"timestamp": 1437805800,
"Import": 1075864
},{
"timestamp": 1437805800,
"Import": 1132356
}]
}]
The problem that I am having though is that sometimes the data might be like this:
[{
"records": [{
"timestamp": 1437805800,
"Import": 1011546e3
},{
"timestamp": 1437805800,
"Import": 1075864e3
},{
"timestamp": 1437805800,
"Import": 1132356e3
}]
}]
Where 101546e3 = 101546x10^3 and this is where I am having issues as the default behavior of json_decode because it will cast these values to float and within that, it converts e3 as 000, or e5 as 00000 so for the first values above I would get back 1011546000, 1075864000, 1132356000. I can't tell that this value had been modified as it may be a valid value.
How am I able to retrieve the correct value (present within the JSON string before running it through json_decode) from this JSON data given that it may contain the string e within what should be an integer value?
101546e3as a numeric field in your JSON and you want to import it as a string. So what you want is a PHP string value that looks like"101546e3". Is that correct?