Soapbox / laravel-formatter

A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class
249 stars 95 forks source link

Error while converting to CSV from JSON #8

Closed ux-engineer closed 9 years ago

ux-engineer commented 10 years ago

Invalid argument supplied for foreach()

  1. ErrorException …\vendor\soapbox\laravel-formatter\src\SoapBox\Formatter\Formatter.php415
  2. Illuminate\Exception\Handler handleError …\vendor\soapbox\laravel-formatter\src\SoapBox\Formatter\Formatter.php415
  3. SoapBox\Formatter\Formatter is_assoc …\vendor\soapbox\laravel-formatter\src\SoapBox\Formatter\Formatter.php162

The JSON seems fine. Could the problem be in that there is an key which value is an object of objects? It works otherwise if I leave that key out.

UPDATE: The same JSON outputs as XML without errors!

grahammccarthy commented 10 years ago

How many levels deep was the JSON that you are trying to convert to CSV?

Can I get a sample set of data from you to investigate?

Thanks!

ux-engineer commented 10 years ago

@grahammccarthy Hey! Have you investigated this issue yet? I would need to have this feature implemented during the next week, so I would really appreciate if you could look into to it some day soon.

Update: I sent you the sample JSON via you website contact form + download link. I can resend it if you cannot find it.

grahammccarthy commented 10 years ago

Hi! It looks like my website blocked your sample JSON. Can you send me an email.

grahammccarthy commented 10 years ago

The problem with the conversion from your specific example is the multi dimentional json to convert into a flat csv.

{
    "simple":"118",
    "date":"2014-05-20 21:03:59.333",
    "time":"4067",
    "duration_onset":null,
    "devicename":"My Device",
    "calc_data":[
        [
            1400609039,
            0,
            37,
            0,
            0,
            1
        ],
        [
            1400609039,
            0,
            37,
            0,
            0,
            1
        ]
    ]
}

I'll see what i can do!

ux-engineer commented 10 years ago

Has there been progress on this?

grahammccarthy commented 10 years ago

Sorry, I gave it a shot over the weekend for an hour and the multi level array conversion to CSV is not well written. I'll have to re-write it, which will take more time. It's a bit busy, and I'm not sure when I can spare some time to work on it. Sorry.

Fusty commented 10 years ago

Hello Graham, is the XML portion also only look a single level deep?

grahammccarthy commented 10 years ago

Hi @Fusty , yeah it does multi level xml! you should be okay to use it. The only problem is multi-level in CSV.