Answers.Body: <p>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:</p>
  
  <pre><code>[
    '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',
      ]
    ]
  ]
  </code></pre>
  
  <p>... or even:</p>
  
  <pre><code>[
    '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',
      ]
    ]
  ]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-28T21:17:37.060Z
Answers.Text: I do like that idea. Structure is good.
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-28T20:44:30.947Z
Answers.LastActivityDate: 2016-09-28T20:44:30.947Z
Answers.UserDisplayName: universalhandle
Body: <p><em>Where (which JIRA issue, if any) did this change in API behaviour come from, and was it documented/expected?</em></p>
  
  <p>The same <code>Contact,get</code> API call returns different results between 4.6 and 4.7. </p>
  
  <p>IMO the new style is better, but I'm not sure the change was intended/documented. (I want clarification so I can expect the new behaviour to stick!)</p>
  
  <p>I've confirmed this behaviour today by testing on the <a href="http://joomla.demo.civicrm.org/" rel="nofollow">4.6 (Joomla)</a> and <a href="http://dmaster.demo.civicrm.org/" rel="nofollow">4.7 (Drupal)</a> demo sites.</p>
  
  <p>API call for <code>Contact,get</code> with <code>return=group</code> shows groups in the results.</p>
  
  <pre><code>civicrm_api3('Contact', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; "group",
    'id' =&gt; 3,
  ));
  </code></pre>
  
  <p>In 4.6 the result has groups shown by their group "title" (not name). Since group titles may contain a comma, there is some lack of certainty in the results (leading to <a href="https://github.com/veda-consulting/uk.co.vedaconsulting.mailchimp/blob/37267ab82260caed96078ead60c4e71c18b5cc2d/CRM/Mailchimp/Utils.php#L27" rel="nofollow">workarounds like this</a>).</p>
  
  <pre><code>[
    'is_error' =&gt; 0,
    'version' =&gt; 3,
    'count' =&gt; 1,
    'id' =&gt; 3,
    'values' =&gt; [
      [
        'contact_id' =&gt; '3',
        'groups' =&gt; 'Example group,Example smart group',
        'id' =&gt; '3',
      ]
    ]
  ]
  </code></pre>
  
  <p>In 4.7 the result has groups shown by their group ID, which is a bit more predictable to work with.</p>
  
  <pre><code>[
    'is_error' =&gt; 0,
    'version' =&gt; 3,
    'count' =&gt; 1,
    'id' =&gt; 3,
    'values' =&gt; [
      [
        'contact_id' =&gt; '3',
        'groups' =&gt; '4,7',
        'id' =&gt; '3',
      ]
    ]
  ]
  </code></pre>
  
  <p>I've checked the <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/API+changes" rel="nofollow">CiviCRM API Changelog</a> and enquired on chat.civicrm.org without any luck so far. Help me, SE!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-28T21:13:49.390Z
Comments.Text: Monish points to [civicrm/civicrm-core @ 3875e6b6](https://github.com/civicrm/civicrm-core/commit/3875e6b655e6ee13b11ccee31cd3a3c0421a0724#diff-e54381bfdf51e31cab376c71ca0d66ffR5694) as origin of the change; if true, this means the API change appears with 4.7.11 via [CRM-17123: Include Transaction ID in membership bulk entry profile](https://issues.civicrm.org/jira/browse/CRM-17123). Not sure that relates to `Contact,get`, perhaps the JIRA issue referenced in the commit is incorrect?
Comments.UserDisplayName: Chris Burgess
Tags: <api><documentation>
Title: CiviCRM Contact,get with group - change in result format
ThreadText: # CiviCRM Contact,get with group - change in result format
  
  (Asked by: username_0 on 2016-09-28)
  
  *Where (which JIRA issue, if any) did this change in API behaviour come from, and was it documented/expected?*
  
  The same `Contact,get` API call returns different results between 4.6 and 4.7.
  
  IMO the new style is better, but I'm not sure the change was intended/documented. (I want clarification so I can expect the new behaviour to stick!)
  
  I've confirmed this behaviour today by testing on the [4.6 (Joomla)](http://joomla.demo.civicrm.org/) and [4.7 (Drupal)](http://dmaster.demo.civicrm.org/) demo sites.
  
  API call for `Contact,get` with `return=group` shows groups in the results.
  
  ```
  civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
    'return' => "group",
    'id' => 3,
  ));
  
  ```
  
  In 4.6 the result has groups shown by their group "title" (not name). Since group titles may contain a comma, there is some lack of certainty in the results (leading to [workarounds like this](https://github.com/veda-consulting/uk.co.vedaconsulting.mailchimp/blob/37267ab82260caed96078ead60c4e71c18b5cc2d/CRM/Mailchimp/Utils.php#L27)).
  
  ```
  [
    'is_error' => 0,
    'version' => 3,
    'count' => 1,
    'id' => 3,
    'values' => [
      [
        'contact_id' => '3',
        'groups' => 'Example group,Example smart group',
        'id' => '3',
      ]
    ]
  ]
  
  ```
  
  In 4.7 the result has groups shown by their group ID, which is a bit more predictable to work with.
  
  ```
  [
    'is_error' => 0,
    'version' => 3,
    'count' => 1,
    'id' => 3,
    'values' => [
      [
        'contact_id' => '3',
        'groups' => '4,7',
        'id' => '3',
      ]
    ]
  ]
  
  ```
  
  I've checked the [CiviCRM API Changelog](https://wiki.civicrm.org/confluence/display/CRMDOC/API+changes) and enquired on chat.civicrm.org without any luck so far. Help me, SE!
  
  **Tags:** api, documentation
  
  > **Comments:**
  > **username_0**: Monish points to [civicrm/civicrm-core @ 3875e6b6](https://github.com/civicrm/civicrm-core/commit/3875e6b655e6ee13b11ccee31cd3a3c0421a0724#diff-e54381bfdf51e31cab376c71ca0d66ffR5694) as origin of the change; if true, this means the API change appears with 4.7.11 via [CRM-17123: Include Transaction ID in membership bulk entry profile](https://issues.civicrm.org/jira/browse/CRM-17123). Not sure that relates to `Contact,get`, perhaps the JIRA issue referenced in the commit is incorrect?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-28. Score: 1
  
  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' => 0,
    'version' => 3,
    'count' => 1,
    'id' => 3,
    'values' => [
      [
        'contact_id' => '3',
        'groups' => array(4, 7),
        'id' => '3',
      ]
    ]
  ]
  
  ```
  
  ... or even:
  
  ```
  [
    'is_error' => 0,
    'version' => 3,
    'count' => 1,
    'id' => 3,
    'values' => [
      [
        'contact_id' => '3',
        'groups' => array('Example group', 'Example smart group'),
        'group_ids' => array(4, 7),
        'id' => '3',
      ]
    ]
  ]
  
  ```
  
  > **Comments:**
  > **username_0**: I do like that idea. Structure is good.  
  
  ---
  
  