Hi,

The main API code is in 
https://github.com/mysociety/theyworkforyou/tree/master/www/docs/api with the 
wrapper API functions in api_functions.php (the other thing linked to is a 
separate Google App Engine application).

To be overly pedantic ;-) The API does not claim the results are actual JSON, 
as far as I'm aware - probably for precisely this reason, that internally 
TheyWorkForYou still uses ISO-8859-1. That being said, it would obviously be 
better if its output were in UTF-8 and it was JSON - so thanks for your offer 
:-)

ATB,
Matthew

On 20 May 2013, at 13:51, Dave Cross wrote:
> I'm doing some work using the TWFY API and I think that some problems I'm 
> getting might be down to it returning incorrect headers (and data).
> 
> For example:
> 
> $ curl --head 
> "http://www.theyworkforyou.com/api/getConstituency?name=Ynys+Mon&output=js&key=$TWFY_KEY";
> HTTP/1.1 200 OK
> Content-Type: text/javascript; charset=iso-8859-1
> x-url: 
> /api/getConstituency?name=Ynys+Mon&output=js&key=CpkcgmCFQJpAAGnb3oE6XHuy
> Content-Length: 201
> Date: Mon, 20 May 2013 12:50:42 GMT
> Age: 0
> 
> It's the Content-Type header that bothers me. I think that's wrong for two 
> reasons. Firstly, it should be 'application/json' and secondly (and more 
> importantly) I thought that JSON should be encoded in UTF-8 by definition.
> 
> As it happens, the charset value is correct. The data I'm getting back *is* 
> ISO-8859-1. But that's a problem for some of the JSON tools that I'm using 
> which are (understandably) confused by JSON that isn't in UTF-8.
> 
> I understand that the differences between ISO-8859-1 and UTF-8 are tiny 
> across all of the data that TWFY holds. The example above is about the only 
> one I can think of. But it's an important one to my application.
> 
> I anyone wanted to point me at the relevant part of your github repo then I'd 
> be happy to attempt a patch. And if I'm bringing this up in completely the 
> wrong place, then please point in the right direction.


_______________________________________________
developers-public mailing list
[email protected]
https://secure.mysociety.org/admin/lists/mailman/listinfo/developers-public

Unsubscribe: 
https://secure.mysociety.org/admin/lists/mailman/options/developers-public/archive%40mail-archive.com

Reply via email to