MediaWiki API 說明
此頁為自動產生的 MediaWiki API 說明文件頁面。
說明文件與範例:https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page
action=wbformatvalue
(main | wbformatvalue)
- 此模組需要讀取權限。
- 來源:WikibaseClient
- 授權條款:GPL-2.0-or-later
格式化資料值。
具體參數:
其他通用參數可用。
- generate
預期得輸出格式
- 單值:text/html、text/html; disposition=verbose、text/html; disposition=verbose-preview、text/plain、text/x-wiki
- 預設值:text/x-wiki
- datavalue
要格式化的資料。這必須是資料值物件的 JSON 序列化。
- 此為必填參數。
- datatype
值的資料類型。不同於值的類型。
- 單值:commonsMedia、external-id、geo-shape、globe-coordinate、monolingualtext、quantity、string、tabular-data、time、url、wikibase-item、wikibase-property
- property
資料值所屬的屬性 ID,應取代 datatype 參數來使用。
- options
格式化應使用的選項。以 JSON 物件作為提供。
範例:
- 格式化簡易字串值。
- api.php?action=wbformatvalue&datavalue=%7B%22value%22%3A%22hello%22%2C%22type%22%3A%22string%22%7D [在沙盒中開啟]
- 在 HTML 裡將字串值格式化為 URL。
- api.php?action=wbformatvalue&datavalue=%7B%22value%22%3A%22http%3A%5C%2F%5C%2Facme.org%22%2C%22type%22%3A%22string%22%7D&datatype=url&generate=text%2Fhtml [在沙盒中開啟]
- Format a time value as plain text, automatically showing the calendar model if needed.
- api.php?action=wbformatvalue&datavalue=%7B%22value%22%3A%7B%22time%22%3A%22%2B1879-03-14T00%3A00%3A00Z%22%2C%22timezone%22%3A0%2C%22before%22%3A0%2C%22after%22%3A0%2C%22precision%22%3A11%2C%22calendarmodel%22%3A%22http%3A%5C%2F%5C%2Fwww.wikidata.org%5C%2Fentity%5C%2FQ1985727%22%7D%2C%22type%22%3A%22time%22%7D&datatype=time&generate=text%2Fplain&options=%7B%22showcalendar%22%3A%22auto%22%7D [在沙盒中開啟]