output JSON
make lsr() return a nested iterator; add flatten() function to flatten nested iterators