Best way to JSON Python get all values for key? Need help! or How to JSON Python get all values for k

18 Replies, 1256 Views

If you're into one-liners (kinda), try this:

```python
values = [y for x in __import__('json').loads(__import__('json').dumps(data)) for y in ([x['a']] if 'a' in x else [])]
```
But... maybe don't. It's ugly. Stick with recursion or a lib.

Messages In This Thread



Users browsing this thread: 1 Guest(s)