Wikibase has several API modules which take JSON blobs of varying sizes
as text parameters, e. g. wbsetclaimvalue [1] or wbeditentity [2].

Cheers,
Lucas

[1]:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/390719923d29a0b3b3867cef62ef6e71c9a7e330/repo/includes/Api/SetClaimValue.php#143
[2]:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Wikibase/+/390719923d29a0b3b3867cef62ef6e71c9a7e330/repo/includes/Api/EditEntity.php#514

On 25.02.20 00:00, Matthew Dowdell wrote:
> Hi All,
>
> I'm writing an API module that I'd like to take 'complex' data for one
> of the parameters, e.g.
>
> {
>     "action": "example",
>     "token": "<some csrf token>",
>     "data": [
>         {"key": "value1", "otherkey": "othervalue1"},
>         {"key": "value2", "otherkey": "othervalue2", "optionalkey":
> "optionalvalue"},
>         {"key": "value3", "otherkey": "othervalue3"}
>     ]
> }
>
> The list in data can grow to several hundred elements all of which
> contain the same 2 keys with an optional third. For reference, I'm
> developing on mw1.31, but I can swap to something more recent if
> that's where new possibilities become available.
>
> This module takes POST requests, so I'd just send it as part of the
> request body, but when it comes to deserialising it, I'm not really
> sure what to deserialise it to as everything seems to assume primitive
> values, e.g. strings, integers, etc. when it comes to setting the
> parameter type. I'm not averse to claiming it's a string and
> deserialising it myself, but my attempts so far haven't proved
> successful. I also tried writing a phpunit test which displayed
> different behaviour (it seems to have quietly lost the value) and
> using the mwapi python library for an integration/end-to-end test
> which caused a third behaviour by quietly joining the elements in the
> list into a string. I get the feeling what I'm trying to do is at the
> very least non-standard for mediawiki.
>
> Does anyone have experience in trying to do this or know of prior art
> that does something similar?
>
> Cheers,
> Matt
>
>
> _______________________________________________
> Mediawiki-api mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
_______________________________________________
Mediawiki-api mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to