Store and retrieve group data as JSON

Encoding and using the jQuery's .data() allows JSON to be automatically decoded on the client side for use.
Storing group names containing commas is no problem for JSON, whereas prior code would use .split(',') to create too many array elements from multiple groups stored as strings, separated with commas.
Fixes #4351