Advertisement
Guest User

Lazy Python json iteration

a guest
Aug 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. def iter_json(json):
  2.     for el in (json.values() if isinstance(json, dict) else json):
  3.         if type(el) is dict or type(el) is list:
  4.             for sub in iter_json(el):
  5.                 yield sub
  6.         else:
  7.             yield el
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement