ImportJSON icon indicating copy to clipboard operation
ImportJSON copied to clipboard

Reordering columns via allHeaders is broken

Open ciscorucinski opened this issue 5 years ago • 1 comments

Let's say I have a JSON response that will create 26 columns worth of data, but I just want the first 3 in reverse order.

=importJson("example.com/json_abcs", "/c, /b, /a") isn't enough. It will give me the 3 columns but in the order as given in the JSON response. I will have to include allHeaders to create the following...

`=importJson("example.com/json_abcs", "/c, /b, /a", "allHeaders")`

However, this no longer works.

There are some bad hacks that involve duplicate data, multiple calls, etc. Bu the fact of the matter is that the ordering of headers is broken.

ciscorucinski avatar Sep 10 '20 09:09 ciscorucinski

I just tried allHeaders and it seems to be working for me. I'm not sure if it was broken before and fixed, but it's working now. Make sure to put the JSON objects in the order you want them to appear (the columns), and then pass the allHeaders parameter at the end. For example, something like: =ImportJSON("https://domain.com/file.json", "/date,/name,/amount", "allHeaders,noInherit,noTruncate")

Also, make sure you have the latest version of the script running. You can get it here: https://github.com/bradjasper/ImportJSON/blob/master/ImportJSON.gs

davidshares avatar Dec 07 '20 16:12 davidshares