fixed to_json for groups.