further implementation of json hierarchy flattening