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

Empty JSON lists wiped out #380

Open
joshfriend opened this issue Jan 5, 2015 · 10 comments

Comments

@joshfriend
Copy link
Member

commented Jan 5, 2015

#261 introduced a bug where if an argument is an empty JSON list, it will be omitted from the argument collection.

@joshfriend joshfriend self-assigned this Jan 5, 2015

@joshfriend joshfriend added this to the 0.3.2 milestone Jan 5, 2015

@joshfriend

This comment has been minimized.

Copy link
Member Author

commented Jan 30, 2015

Also wipes out all the but the first element of non-empty lists

@joshfriend

This comment has been minimized.

Copy link
Member Author

commented Feb 2, 2015

Appears to be a regression introduced by #261

@joshfriend joshfriend modified the milestones: 0.3.2, 0.3.3 Feb 26, 2015

@joshfriend

This comment has been minimized.

Copy link
Member Author

commented Feb 28, 2015

>>> from werkzeug.datastructures import MultiDict
>>> x = {'empty_list': []}
>>> y = MultiDict()
>>> y
MultiDict([])
>>> y.update(x)
>>> y
MultiDict([])
>>> y['empty_list'] = []
>>> y
MultiDict([('empty_list', [])])
@joshfriend

This comment has been minimized.

Copy link
Member Author

commented Feb 28, 2015

Only happens when using the default location=('json', 'values'). Works fine when location='json'

@odarbelaeze

This comment has been minimized.

Copy link

commented Jan 23, 2018

Looks like this doesn't work anymore with 0.3.6, a list of strings passed in the json is interpreted like ['t', 'h', 'i', 's'] instead of ['this'].

@Kokosso

This comment has been minimized.

Copy link

commented Feb 10, 2018

@odarbelaeze
Hey, I add one string into reqparse.py.
value = ''.join(value).

@gabll

This comment has been minimized.

Copy link

commented Feb 15, 2018

I confirm, while putting location='json' was working in 0.3.5 as @joshfriend mentioned, in 0.3.6 isn't enough and it splits the string.

@ArtemChekunov

This comment has been minimized.

Copy link

commented Mar 15, 2018

Hello @joshfriend could you reopen the issue.
In 0.3.6 it is not works

@joshfriend joshfriend reopened this Mar 15, 2018

@mayasankar

This comment has been minimized.

Copy link

commented Jun 25, 2018

A workaround I found is using the options required=False, type=str, action='append', default=[] if you want a list of strings. However, this does not distinguish between having value [] and not being specified.

@stefanbschneider

This comment has been minimized.

Copy link

commented Feb 6, 2019

Dosn't work for me. I get TypeError: sequence item 1: expected str instance, list found when using [] as default, even though I specify type=str.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.