Convert object to json. How to group objects in json.