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

jsondatetime fails parsing lists #5

Open
kaleko opened this issue Jan 11, 2019 · 1 comment
Open

jsondatetime fails parsing lists #5

kaleko opened this issue Jan 11, 2019 · 1 comment

Comments

@kaleko
Copy link

kaleko commented Jan 11, 2019

If the json file being read in has a list of non-datetime values, for example
"mykey" : [ 123, 456 ],

the parser will fail with
AttributeError: 'int' object has no attribute 'items'

This comes from the iteritems(source) function. I was able to fix it with:
for k, v in source.items():
if isinstance(v, list):
#Note this probably will fail for a list of datetimes, but as of now that is not used
pass

but this will probably fail for a list of datetime objects. I haven't figured out how to solve it more generally for lists of ints and for lists of datetime objects.

@amarvin
Copy link

amarvin commented Dec 9, 2022

Maybe a test could be added for the simplest case where the JSON is just a list:

>>> import jsondatetime as json
>>> json.loads("[]")
AttributeError: 'list' object has no attribute 'items'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants