Use JSON to send/receive group data.

Squashed commits from PR #4364 for master backport.
For #4351 on master.