Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for toplevel arrays #1402

Closed
wants to merge 3 commits into from
Closed

Add support for toplevel arrays #1402

wants to merge 3 commits into from

Conversation

tonyxty
Copy link

@tonyxty tonyxty commented Mar 27, 2015

Multiple issues including #248 call for jsonify to handle lists. As discussed there, allowing toplevel arrays should pose no security problem nowadays. A config parameter is added to enable this functionality, and an array is returned only when a conversion to an object is not possible to maintain backwards compatibility.

In short, when JSONIFY_ALLOW_TOPLEVEL_ARRAY is set, jsonify(1, 2, 3), jsonify(question='Ultimate', answer=42), and jsonify({'question': 'Ultimate', 'answer': 42}) all work as expected. Note that unlike dicts, jsonify([1, 2, 3]) will result in nested lists, so always use jsonify(*l) for a list variable l.

jsonify(1, 2, 3) will work while jsonify([1, 2, 3]) will result in
nested lists.
@davidism davidism closed this Jan 25, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants