Added option to flatten json and set it it true by default