added code to convert json tree structure to flat map