You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
3000 release annouced the deprecation of json_decode_dict is not equalivant as tojson #55911
I was looking at the documentation and it doesn't appear to have anything indicating that the output between those 2 flags are different, just that tojson is suppose to replace it. Is having them sorted unwanted behavior?
Depending on what output we're trying to cast, order might be imporant. For me a lot of things I had in a specific order got sorted alphabetically. e.g. some share templates showed up after the share that used them, resulting in errors in the smb.conf
If one wanted the correct behavior of a function called json_decode_dict, tojson is the right filter. What json_decode_dict did originally is not json_decode_dict, it was doing json_encode_dict.
Basically you could think of it as being called "undo" when it should have been "do".
And for most cases, people were looking for "do", and tojson is what they're wanting.
I'm going to go ahead and close this issue, but reproducing it has exposed a potential issue when migrating from 2 to 3.
Activity
xeacott commentedon Jan 21, 2020
I was looking at the documentation and it doesn't appear to have anything indicating that the output between those 2 flags are different, just that
tojsonis suppose to replace it. Is having them sorted unwanted behavior?Here's the docs page for reference too... https://jinja.palletsprojects.com/en/2.10.x/templates/#tojson
sjorge commentedon Jan 21, 2020
Depending on what output we're trying to cast, order might be imporant. For me a lot of things I had in a specific order got sorted alphabetically. e.g. some share templates showed up after the share that used them, resulting in errors in the smb.conf
xeacott commentedon Jan 21, 2020
Understood, so it seems quite undesirable especially when it isn't clear to the user. Thanks for the report!
waynew commentedon Jan 24, 2020
@sjorge
json_decode_dictis actually an incorrectly named function, which is why it was deprecated in 2018.3.0.To retain the same functionality, use
json_encode_dict:The
tojsonfilter provides a different functionality, and actually comes from the Jinja library.2 remaining items
waynew commentedon Jan 28, 2020
If one wanted the correct behavior of a function called
json_decode_dict,tojsonis the right filter. Whatjson_decode_dictdid originally is notjson_decode_dict, it was doingjson_encode_dict.Basically you could think of it as being called "undo" when it should have been "do".
And for most cases, people were looking for "do", and
tojsonis what they're wanting.I'm going to go ahead and close this issue, but reproducing it has exposed a potential issue when migrating from 2 to 3.
Test that our tojson is used over jinja's
Test that our tojson is used over jinja's