[ckan-dev] Ckan JSON output

Toby Dacre toby.okfn at gmail.com
Thu Jun 27 09:38:30 UTC 2013


On 27 June 2013 10:01, Ross Jones <ross at servercode.co.uk> wrote:
>
> 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.

I think some tests check for exact output (which is clearly wrong)

>
> 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.

do you have any more info on this? have you done any performance testing?

>
> Ross
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev



-- 
Toby Dacre

The Open Knowledge Foundation

Empowering through Open Knowledge
http://okfn.org/  |  @okfn




More information about the ckan-dev mailing list