When selecting one column how do I just get a list instead of a list of dictionaries?

32 views Asked by At

My query is https://data.seattle.gov/resource/y2d4-ftqb.json?$group=categories&$select=categories&$where=categories%20IS%20NOT%20NULL

Output is

[{"categories":"Training|Use of Force"}
,{"categories":"Narcotics"}
,{"categories":"Traffic|Assist"}
,{"categories":"Burglary"}
,{"categories":"Crisis"} ...

How do I get the output to be:

["Training|Use of Force", "Narcotics", "Traffic|Assist", "Burglary", "Crisis",...]

?

1

There are 1 answers

0
kaveman On BEST ANSWER

Instead of requesting the json endpoint (which is causing you to get an array of objects back), you could instead request the csv endpoint:

https://data.seattle.gov/resource/y2d4-ftqb.csv?$group=categories&$select=categories&$where=categories%20IS%20NOT%20NULL

This returns a single header line ("categories") and then each non-null category as a regular string, on its own line:

"categories"
"Training|Use of Force"
"Narcotics"
"Traffic|Assist"
"Burglary"
"Crisis"
...