简体   繁体   English

Python JSONDecode错误,因为数字以0开头

[英]Python JSONDecode Error because a number starts with 0

I'm trying to load a json file using requests and I am getting an error 我正在尝试使用请求加载json文件,我收到错误

>>> r = requests.get('urlto.json').json()

JSONDecodeError: Expecting ',' delimiter or '}': line 11 column 418 (char 6232)

This is the json in question: 这是有问题的json:

{"Resource Name":"","Contact Name":null,"Contact Email":null,"Primary Phone":"","Primary Phone Ext":null,"Alternate Phone":null,"Alternate Phone Ext":null,"TTY":null,"Website URL":"","Website Tiny URL":null,"Website Name":null,"Email":"","Street Address":"","Street Address 2":null,"City":"","State":"MA","Postal Code":01331,"Description":null,"Category":null,"Tags":null,"Notes":null,"Services":null,"Longitude":null,"Latitude":null,"Thumbnail":null},

The problem is that the postal code starts with a 0. The other postal codes that come before this don't throw an error. 问题是邮政编码以0开头。之前的其他邮政编码不会引发错误。 If I quote that postal code, it doesn't throw an error. 如果我引用该邮政编码,它不会引发错误。 How can I get around this? 我怎么能绕过这个?

Yes, I see now that it is invalid json. 是的,我现在看到它是无效的json。 Thank you 谢谢

How do I close/delete this question? 如何关闭/删除此问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM