Used spray-json JsonFormat for converting object to json.