askargs: units of measurement

From semantic-mediawiki.org
Fragment of a discussion from Help talk:API

It's even worse. It seems that all export features {{#askargs:}}, {{#ask:}}, csv and json formats simply ignore # in printouts (only showing units of measurement in the "printrequests").

10:03, 13 November 2014

So, I have to convert units of measurements in my client application again, although it could have ben done by SMW. The application should know the conversion rates etc.

But even that is made difficult. The required units (when shown at all) are not in the query.results [(label)].printouts objects but in the query.printrequests. Moreover, while query.results [(label)].printouts is an object, query.printrequests is an array, so I cannot just go there and get the unit, I have to traverse the array at least once to convert in to an object with the same indices as query.results [(label)].printouts. Why? Why? Why?

I have to parse JSON, which is supposed to be parsed already, in dozens of lines of code; just because there is no sane way to get quantities in needed units in the API, or at least, it is not documented.

11:01, 18 November 2014

I suspect you are right that the ask API does not support units. You should be able to use Special:Ask though. And enhancements to the ask API, or its documentation, are certainly welcome.

09:01, 24 December 2014

My task was to make a fully dynamic (not cached with the rest of the wikipage) semantic map. At first I used SMW API and had to process units of measurement in my JavaScript. Then I found a more universal and robust solution: I developed an extension that enables server- and client-side inclusions on wikipages (with api.php?action=parse). So, this issue is not so pressing to me now. However, I still think that there is a bug in the API, not its documentation.

03:43, 25 December 2014