Last modified: 2013-12-09 15:04:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T47470, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 45470 - Provide JSON library/module by default
Provide JSON library/module by default
Status: PATCH_TO_REVIEW
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Low enhancement with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
usability
:
Depends on:
Blocks: 48176
  Show dependency treegraph
 
Reported: 2013-02-27 01:00 UTC by Danny B.
Modified: 2013-12-09 15:04 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Danny B. 2013-02-27 01:00:27 UTC
Some JSON library/module should be provided by default.

Comparison http://lua-users.org/wiki/JsonModules
Comment 1 Brad Jorsch 2013-03-01 19:40:56 UTC
There is no use case for this:
* Normal data can be stored as Lua tables in a submodule and loaded with
  mw.loadData()
* Data passed in from templates should be formatted in a manner friendly to
  non-technical users rather than being some blob of JSON
* It's unlikely that an {{#invoke:}} will be used in any context where it makes
  sense to return json rather than wikitext.
Comment 2 Danny B. 2013-03-03 22:37:04 UTC
There is very nice usecase, otherwise I wouldn't actually file this request.

If you need same data for AJAX JS as well as to be used in the module. Then you will store it only once in JSON format, so it will be available for both JS and Lua.

Please don't close bugs just because you *think* there is no usecase.
Comment 3 Andre Klapper 2013-03-05 10:09:37 UTC
(In reply to comment #2)
> Please don't close bugs just because you *think* there is no usecase.

Please always provide a usecase in your initial description if you want to avoid getting WONTFIXed.  :)  https://www.mediawiki.org/wiki/How_to_report_a_bug
Comment 4 Andre Klapper 2013-03-08 18:17:14 UTC
Danny: Could you clarify what "some data for JS" is, how it would be "used in the module", and what you'd use it for in both Lua and JS?
Sorry for the hassle, but your example feels still a bit too generic to actually understand the usecase.
Comment 5 Andre Klapper 2013-04-11 13:39:39 UTC
Danny: Could you clarify what "some data for JS" is, how it would be "used in
the module", and what you'd use it for in both Lua and JS?
Comment 6 Danny B. 2013-04-15 23:10:12 UTC
Say you have JSON "database" of some data you want to use both in JavaScript (gadget) as well as in Lua (module).

Trivial (but rather artificial) example:
Array of pairs country code - country name.
Gadget where you put country code in input and it will generate some text to be input into the editbox.
Module where the template param is the country code and it generates some output.
Both need the country name.

Doesn't make a sense to have two "databases", one in JavaScript, one in Lua. Synchronization issues obviously.


----


Another example for why this would be helpful:

Sharing tables between modules via (de)serialization:

Trivial (again artificial for making it really simple) example again:

{{parent|param={{child|foo|bar|baz}}}}

child does #invoke:child, parent does #invoke:parent

module:child simply builds the table { "foo", "bar", "baz" }

module:parent takes the built table (currently impossible, because module can return text only) and uses whatever is there for own purposes
Comment 7 Ori Livneh 2013-04-16 08:55:51 UTC
http://www.mediawiki.org/wiki/Module:JSON
..works well enough for my purposes.
Comment 8 Danny B. 2013-04-16 10:58:49 UTC
Nice, but having such functions provided by default, yet preferably as binaries, thus even better performance, would be obviously better (and this bug is about it). But thanks for the (hopefuly temporary) workaround.
Comment 9 Kunal Mehta (Legoktm) 2013-05-06 23:31:08 UTC
One more use case: https://www.wikidata.org/wiki/Module:WBHacks which is using https://www.wikidata.org/wiki/Module:JSON (different than Ori's). It's hitting the execution limit on pages like https://www.wikidata.org/wiki/Wikidata:P, so a native JSON module might make it faster.
Comment 10 Gerrit Notification Bot 2013-09-21 14:18:02 UTC
Change 85426 had a related patch set uploaded by Tpt:
(bug 45470) Add mw.json

https://gerrit.wikimedia.org/r/85426
Comment 11 Rainer Rillke @commons.wikimedia 2013-11-26 00:27:50 UTC
(In reply to comment #1)
>Data passed in from templates should be formatted in a manner friendly to
>non-technical users rather than being some blob of JSON

Ha!
Sure that's why TemplateData and Upload Wizard Campaigns force the user entering raw JSON-data-blobs. From the perspective of their developers and Mr. James Forrester that's totally okay. For me, it wasn't but when I tried to change that, I was accused of "derailing Commons" by them.

(In reply to comment #5)
> Could you clarify what "some data for JS" is, how it would be "used in
> the module", and what you'd use it for in both Lua and JS?
Curretnly I have data (only small that's why I do not complain) in JSON-format for JavaScript, in AbuseFilter format and in Lua format for some edit notice at Commons. JSON is a well-accepted standard and having a fast, native parser and generator would be pretty much useful.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links