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

How to fix IncompleteJSONError #50

Closed
ShawnLin-pku opened this issue May 5, 2021 · 3 comments
Closed

How to fix IncompleteJSONError #50

ShawnLin-pku opened this issue May 5, 2021 · 3 comments
Labels
invalid This doesn't seem right question Further information is requested

Comments

@ShawnLin-pku
Copy link

ShawnLin-pku commented May 5, 2021

I have come across the error when using ijson to parse big json file

IncompleteJSONError: lexical error: invalid char in json text.
                        {      "_id" : ObjectId("5e5d193d8cf3fe97fa488
                     (right here) ------^

My source code is as followed:

with codecs.open('lagou.json','rb') as f:
    objects = ijson.items(f,'item')
    print(objects.__next__())

It really confuses me that why character 'b' will be a invalid char

@rtobar rtobar added the question Further information is requested label May 5, 2021
@rtobar
Copy link

rtobar commented May 5, 2021

(I took the liberty of editing the original question for correct formatting)

@ShawnLin-pku your JSON document is not valid: ObjectId is not a valid token in JSON. It looks like you have a document that looks like JSON, but isn't strictly JSON.

@rtobar rtobar closed this as completed May 5, 2021
@ShawnLin-pku
Copy link
Author

(I took the liberty of editing the original question for correct formatting)

@ShawnLin-pku your JSON document is not valid: ObjectId is not a valid token in JSON. It looks like you have a document that looks like JSON, but isn't strictly JSON.

Thanks for your reply. I exported this document from mongo database. So how can I load this file using ijson's iterator? (It's so big that I can't load it directly in memory)

@rtobar rtobar added the invalid This doesn't seem right label May 5, 2021
@rtobar
Copy link

rtobar commented May 5, 2021

@ShawnLin-pku you can't load it with ijson because it's not a valid JSON document, it just looks very much like one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants