Update tojson to allow arbitrary args#56022
Conversation
f2a0391 to
09b21e2
Compare
|
@waynew it looks failures are related. |
fb41c6c to
da7d833
Compare
90da99e to
644b723
Compare
95072df to
4895666
Compare
|
rebased + py2 drop precommit. Should be good now (or in a couple hours when all tests are done) |
|
ping @waynew theres some failing tests here |
|
moving this to another release |
We're already vendoring the filter, which also has less features than what we want to support.
2b8c235 to
21d32c2
Compare
I goofed and was not sorting in one test - that's fixed. The other test was failing because earlier versions of Python don't remember dict insertion/creation order. Without sorting the output order was accidental. On certain platforms they were accidental in a different order than expected, so this caused a problem. Changing to OrderedDict allows us to specify the order, and this should work on those older versions of Python.
|
@sagetherage hopefully this should pass the broken tests -- I fell victim to one of the classic blunders - no, not "Never get involved in a land war in Asia,"... and no, not "Never go up against a Sicilian when death is on the line" This one was, "Earlier versions of Python are arbitrary with their dictionary ordering no matter how lucky you think you are." Anyway, this should be better now, please let me know if it isn't! |
|
@waynew Note that the .. jinja_ref:: tojson
``tojson``
----------
.. versionadded:: 2018.3.3,2019.2.0
Dumps a data structure to JSON.
This filter was added to provide this functionality to hosts which have a
Jinja release older than version 2.9 installed. If Jinja 2.9 or newer is
installed, then the upstream version of the filter will be used. See the
`upstream docs`__ for more information.I.e. This part:
|
What does this PR do?
The builtin Jinja tojson filter only supports
indentas an arg that can be passed to the underlying json dump function. This doesn't allow all the functionality people might want.This updates the
tojsonfilter to allow arbitrary keyword arguments to be passed along to the underlying JSON library.What issues does this PR fix or reference?
#55911 and closes #56012
Previous Behavior
It was impossible to get unsorted JSON, or use other functionality.
New Behavior
It's possible to specify sorted or unsorted JSON, as well as pass arbitrary arguments to the underlying JSON dump function.
Tests written?
Yes
Commits signed with GPG?
Yes