With formatversion=2, we can make some useful changes:
- Return booleans as boolean true instead of empty-string. Where appropriate,[1] return boolean false instead of omitting the property.
- Return empty objects in JSON as {}, rather than [].
- Have action=query's "pages" be an array, instead of an object with page ids as keys that can be difficult to iterate.
- Provide useful property names instead of '*'.
- Eliminate useless indirection, e.g. {"text":"..."} instead of {"text":{"*":"..."}} and {"key1":"value1","key2":"value2"} instead of [{"name":"key1","*":"value1"},{"name":"key2","*":"value2"}].
If you see missed opportunities to make the above changes in existing formatversion=2 output, or if there are other changes that would make API output easier to use in JSON, please let me know!
Phabricator would be ideal (tag with
#MediaWiki-API, and the appropriate extension's tag if applicable), or reply on the
mediawiki-api mailing list.
Thanks.
[1]: Where the property is usually false, it's sometimes just bloat to include it.
--
Brad Jorsch (Anomie)
Software Engineer
Wikimedia Foundation