changed jsonToString function to support orderby