pysimdjson
pysimdjson copied to clipboard
Check for `None` key fails when using `parse`
Issue Description
When using simdjson.Parser.parse, checking if a None key exists in the parsed object results in a TypeError: expected bytes, NoneType found.
Example Code:
import simdjson
parser = simdjson.Parser()
doc = parser.parse(b'{"res": [{"name": "first"}, {"name": "second"}]}')
if not None in doc: # This line raises the error
pass
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "simdjson/csimdjson.pyx", line 316, in csimdjson.Object.__contains__
TypeError: expected bytes, NoneType found
Expected Behavior
The check should return False (as it does with simdjson.loads), since None is not a valid JSON key.
Working Example with simdjson.loads:
import simdjson
doc = simdjson.loads(b'{"res": [{"name": "first"}, {"name": "second"}]}')
if not None in doc: # Correctly returns False
pass