You can totally subclass `JSONDecoder` to skip fields! Override the `decode` method and filter out unwanted keys before parsing.
Here's a quick example:
```python
class FilteringDecoder(json.JSONDecoder):
def __init__(self, *args, **kwargs):
self.skip_keys = kwargs.pop('skip_keys', set())
super().__init__(*args, **kwargs)
def decode(self, s):
obj = super().decode(s)
return {k: v for k, v in obj.items() if k not in self.skip_keys}
```
Not the *most* efficient since it still parses everything, but cleaner than post-filtering. For huge JSON, maybe try `ijson` for streaming.
Here's a quick example:
```python
class FilteringDecoder(json.JSONDecoder):
def __init__(self, *args, **kwargs):
self.skip_keys = kwargs.pop('skip_keys', set())
super().__init__(*args, **kwargs)
def decode(self, s):
obj = super().decode(s)
return {k: v for k, v in obj.items() if k not in self.skip_keys}
```
Not the *most* efficient since it still parses everything, but cleaner than post-filtering. For huge JSON, maybe try `ijson` for streaming.
