[ckan-dev] corupted JSON-string with API search
Sean Hammond
sean.hammond at okfn.org
Fri Aug 24 12:25:45 UTC 2012
> the search URL for the call is <IP>/api/search/dataset?sort=metadata_modified+desc&all_fields=1&limit=10
> the result is like this:
> ...
> extras": {
> "geographical_granularity": "",
> ...
> "comments": "{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}",
> ...
> }
>
> but when calling the dataset directly I get the correct resonse:
> ...
> "extras": {
> "geographical_granularity": "",
> ...
> "comments": [
> {
> "date": "Tue Aug 21 13:01:48 GMT 2012",
> "comment": "testing ckan",
> "userId": "11702"
> }
> ],
> ...
> ...
I think I'm getting a similar problem on CKAN master. I created a
dataset with an extra with key "comments" and a JSON list as value:
[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]
When I visit http://127.0.0.1:5000/api/search/dataset?sort=metadata_modified+desc&all_fields=1&limit=10
I'm seeing my JSON value as a string the same as in your example.
(Actually when I visit the search URL in CKAN 1.7.1 I don't see my extra
value at all, it seems that search didn't return extras in 1.7.1, are
you actually using CKAN 1.8?).
I don't get a response like yours when I call the dataset directly,
e.g. /api/rest/dataset/warandpeace or /api/action/package_show?id=warandpeace,
with /rest/dataset:
"extras": {
"comments": "[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]"
},
with package_show:
"extras": [
{
"state": "active",
"value": "\"[{u'date': u'Tue Aug 21 13:01:48 GMT 2012', u'comment': u'testing ckan', u'userId': u'11702'}, {u'date': u'Wed Aug 22 13:01:48 GMT 2012', u'comment': u'testing ckan again', u'userId': u'11702'}]\"",
"revision_timestamp": "2012-08-24T12:07:15.992601",
"package_id": "94e3c804-f902-4316-abb1-246ddd1056a5",
"key": "comments",
"revision_id": "8511b279-a610-410b-b679-f29518073aa4",
"id": "d85d6d5f-795c-4af7-9dfc-cb4eb6ee4bf7"
}
What URL are you visiting when you call the dataset directly?
I've created a ticket for this issue but I think that's all I can do
about it right now:
http://trac.ckan.org/ticket/2889
More information about the ckan-dev
mailing list