Hi all, First, thank you for viewing my post. I'm working on product to get information from wiki and show them in office application. And when I am working with MediaWiki APIs, I found a problem. I use C# to build my application and I get the query result from MediaWiki by Json format. And my problem is that Some APIs will return a json object which cannot be deserialized to a C# object. For example, when I try to get the image list of Seattlehttp://en.wikipedia.org/wiki/Seattle,(the request url is thishttp://en.wikipedia.org/w/api.php?action=query&prop=images&imlimit=6&titles=Seattle&format=json) The result will be: [image: JSON%20result.jpg] Please check the red box in the picture above. As we know that JSON is a key/value based format and in the red box, this key is dynamically generated according to the page id. in this way, this json is unable to be deserialized to a C# object since I have to map a C# property to a const key/ID in code. I just wonder why MediaWiki do this? if MediaWiki APIs wants to support to show multipage in query result, probably it should use Array to show all page info?
On Wed, Jul 6, 2011 at 7:36 AM, Justin Zhang justinzh@teammersion.com wrote:
Hi all, First, thank you for viewing my post. I'm working on product to get information from wiki and show them in office application. And when I am working with MediaWiki APIs, I found a problem. I use C# to build my application and I get the query result from MediaWiki by Json format. And my problem is that Some APIs will return a json object which cannot be deserialized to a C# object. For example, when I try to get the image list of Seattle,(the request url is this) The result will be:
This image got scrubbed by the mailing list.
Please check the red box in the picture above. As we know that JSON is a key/value based format and in the red box, this key is dynamically generated according to the page id. in this way, this json is unable to be deserialized to a C# object since I have to map a C# property to a const key/ID in code. I just wonder why MediaWiki do this? if MediaWiki APIs wants to support to show multipage in query result, probably it should use Array to show all page info?
Yes, JSON uses page IDs as keys. If this is inconvenient in your language (as it is in JavaScript), you can set &indexpageids=1 and you'll get an array of the page IDs used added to the result. That's really the best I can do for you at this point; we did not and will not design our output formats around the limitations of a specific C# deserializer (JavaScript and PHP can work with this just fine, it's really a limitation of your language or library).
Roan Kattouw (Catrope)
Roan Kattouw wrote:
On Wed, Jul 6, 2011 at 7:36 AM, Justin Zhangjustinzh@teammersion.com wrote:
Hi all, First, thank you for viewing my post. I'm working on product to get information from wiki and show them in office application. And when I am working with MediaWiki APIs, I found a problem. I use C# to build my application and I get the query result from MediaWiki by Json format. And my problem is that Some APIs will return a json object which cannot be deserialized to a C# object. For example, when I try to get the image list of Seattle,(the request url is this) The result will be:
This image got scrubbed by the mailing list.
Interestingly, it arrived here in the html version (it contained just [image: JSON%20result.jpg] in the plain text one).
It was a hotlinked image to https://byfiles.storage.live.com/y1p5xfyV5vom67VZyCCCtuVjJTK4CA3Xk8AF0XtwxRv...
Please check the red box in the picture above. As we know that JSON is a key/value based format and in the red box,
this key is dynamically generated according to the page id. in this
way, this json is unable to be deserialized to a C#
object since I have to map a C# property to a const key/ID in code. I just wonder why MediaWiki do this? if MediaWiki APIs wants to support to show multipage in query result, probably it should use Array to show all page info?
Can't you iterate the keys?
mediawiki-api@lists.wikimedia.org