Problem with JSON convert
PYovchevski opened this issue · 1 comments
Is there some option to show the empty fields in JSON string as empty string.
The problem is that $excel->toString('JSON') skip the empty fields and if I try to get the content of column X, the content type doesn't match with other rows column X content.
For example
The output array is:
array(3) {
[0]=> string(?) "Title"
[1]=> string(?) "Quantity"
[2]=> string(?) "Price"
}
array(3) {
[0]=> string(?) "BMW"
[1]=> string(?) "5"
[2]=> string(?) "$192.000"
}
array(2) {
[0]=> string(?) "Mercedes"
[1]=> string(?) "$204.000"
}
array(3) {
[0]=> string(?) "Audi"
[1]=> string(?) "10"
[2]=> string(?) "$150.000"
}
So, when I'm trying to get all quantites result is:
5, $204.000, 10
Looking at the JSON parser class it does not appear there is currently a way to include empty cells. However, it should not be terrible difficualt to add said functioanlity to the parser class. Take a look here https://github.com/faisalman/simple-excel-php/blob/master/src/SimpleExcel/Parser/JSONParser.php . My hunch would be to add a boolean, default to false as to not break backward compatibility, that would include empty cells in the JSON output.