[Developers] Change in JSON output
Will Moffat
willmoffat at metaweb.com
Wed Mar 4 17:44:10 UTC 2009
Dear Developers,
The JSON output by the mqlread API has changed yesterday. Forward
slashes are now escaped (which is ugly but legal JSON).
To avoid dependancy on the particular JSON format, we recommend
parsing any JSON string before using the response.
Apologies for not highlighting this change in advance.
(This might be a good time to plug sandbox-freebase.com which lets you
test your code against our APIs ahead of the official release cycle)
regards,
--Will
Example of the new output:
-------------------------------------
http://www.freebase.com/api/service/mqlread?query={"query":{"id":"/
type/int"}}
{
"code": "\/api\/status\/ok",
"result": {
"id": "\/type\/int"
},
"status": "200 OK",
"transaction_id": "cache;cache01.p01.sjc1:8101;2009-03-04T17:28:13Z;
0044"
}
Parsing in Python:
-------------------------
import urllib, simplejson
url='http://www.freebase.com/api/service/mqlread?query={"query":
{"id":"/type/int"}}'
simplejson.load(urllib.urlopen(url))
{u'code': u'/api/status/ok',
u'result': {u'id': u'/type/int'},
u'status': u'200 OK',
u'transaction_id':
u'cache;cache01.p01.sjc1:8101;2009-03-04T17:32:04Z;0044'}
Parsing in JS - http://www.json.org/js.html
------------------
JSON.parse(json_str)
More information about the Developers
mailing list