[ckan-dev] Ckan JSON output

Ross Jones ross at servercode.co.uk
Thu Jun 27 09:01:08 UTC 2013


Hi Toby,

On 27 Jun 2013, at 09:35, Toby Dacre <toby.okfn at gmail.com> wrote:

> JSON output from the api has been changed to now display utf-8 chars
> correctly in https://github.com/okfn/ckan/pull/846 This is targeted at
> CKAN 2.2 unless Adriá feels like taking it for 2.1
> 
> output was:
> {..., "type": "Jeu de donn\u00e9es (S\u00e9rie de donn\u00e9es)" , ...}
> 
> new output:
> {..., "type": "Jeu de données (Série de données)", …}

That sounds great, getting it into 2.1 would be great if you guys can manage it 
and it's not too late.

> Following on from this I would like to change the JSON output to be
> more user friendly.  The basic change would be to change
> `json.dumps(response_data)` to
> `json.dumps(response_data, sort_keys=True, indent=2, separators=(',', ': '))`
> 
> Does this seem to be a useful change?  Would we want a config option
> to retain existing behaviour? or do we want to do this via a param eg
> ?readable=true

I'm not sure why this would break stuff. Seems like a reasonable thing but I doubt most
would care about it being human readable - maybe I'm wrong. Seems reasonably harmless
unless people are decoding the json manually.

Might you also consider switching to json.dump instead of json.dumps?  The latter just 
seems unnecessarily wasteful. I doubt it shows up in testing, but it definitely makes a difference
if the API is under load.

Ross



More information about the ckan-dev mailing list