Michael Stummvoll schreef:
> Hello Mailinglist,
>
> The JSON-Output in the Opensearch-Modul has a few mistakes.
>
> First, a JSON-String have to start with an '{' and ends with '}'
>   
The output is not a string, but an array. Arrays are wrapped in {} 
(indexed), or [] (unindexed).
> but <http://de.wikipedia.org/w/api.php?action=opensearch&search=Te> 
> gives me
> ["Te",["TE","Te","Te 2\/2","Te Ana-au Caves","Te Anau","Te Aroha","Te 
> Atairangikaahu","Te Atua Mou E","Te Aupouri","Te Aup\u014duri"]]
>   
That's perfectly legal for a nested unindexed array.
> also, there are not so much informations as in the xml-output.
>
> I want to propose a better output-formating, that is more confirm (all 
> other json-outputs are in this form):
>
> <http://dict.leo.org/ende?lp=ende&p=thMx..&search=to>{
>     "opensearch" : {
>           "query":"Te",
>           "items" : [
>                {
>                    "title":  "TE",
>                    "description": "Te 2/2 ist eine Sammelbezeichnung für 
> zweiachsige, elektrisch betriebene Rangiertraktoren in der Schweiz.",
>                    "url": "http://de.wikipedia.org/wiki/Te_2/2";,
>                    "image": 
> "http://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Filisur_RhB_71.JPG/50px-Filisur_RhB_71.JPG";
>                 } ,
>                 {
>                       .... (the same for the next result) ...
>                 },
>                      .... (and all results) ...
>           ]
>     }
> }
>
> Is it possible to change that in the api-module?
No, because the OpenSearch format *requires* the output to be in this 
form. OpenSearch is used for things like search suggestions while typing 
something in Firefox's search bar.

If you want the same output in regular JSON, use 
http://en.wikipedia.org/w/api.php?action=query&list=allpages&apprefix=Te&aplimit=10
 
. To get more information about the pages than just the title, use a 
generator: 
http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gapprefix=Te&gaplimit=10&prop=info
 
.

Roan Kattouw (Catrope)

_______________________________________________
Mediawiki-api mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to