transfer message and group to json to send to frontend