CiviCRM Contact,get with group - change in result format
This is not an answer to your question, but were I to post it as a comment the whole thing would be on one line/unreadable. It seems to me that the most desirable format is:

[
  'is_error' =&gt; 0,
  'version' =&gt; 3,
  'count' =&gt; 1,
  'id' =&gt; 3,
  'values' =&gt; [
    [
      'contact_id' =&gt; '3',
      'groups' =&gt; array(4, 7),
      'id' =&gt; '3',
    ]
  ]
]


... or even:

[
  'is_error' =&gt; 0,
  'version' =&gt; 3,
  'count' =&gt; 1,
  'id' =&gt; 3,
  'values' =&gt; [
    [
      'contact_id' =&gt; '3',
      'groups' =&gt; array('Example group', 'Example smart group'),
      'group_ids' =&gt; array(4, 7),
      'id' =&gt; '3',
    ]
  ]
]