# Getting Data From a Repeat Group

**URL:** <https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529>\
**Category:** Developers\
**Created:** [December 21, 2015, 7:53am UTC](https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529 "2015-12-21T07:53:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hikesh\_Hasmukh](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/h/f6c823/32.png) [@Hikesh\_Hasmukh](https://forum.dimagi.com/u/Hikesh_Hasmukh)\
**Post date:** [December 21, 2015, 7:53am UTC](https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529/1 "2015-12-21T07:53:24Z")

</div>

When i try to get data from a repeat group, instead of returning an array,  
if it's one object it returns a single object instead of an array, for  
multiple objects it returns an array.

I think it should return an array in both cases in order to allow parsing  
of these objects.

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [December 21, 2015, 6:33pm UTC](https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529/2 "2015-12-21T18:33:19Z")

</div>

Hi Hikesh,

Can you clarify what you are referring to when you say "get data".

Unfortunately our JSON format doesn't know at submission-time whether  
something is a repeat group or a regular group, which is why this behavior  
exists. I believe you should be able to use commcare export  
[https://confluence.dimagi.com/display/commcarepublic/CommCare+Data+Export+Tool](https://confluence.dimagi.com/display/commcarepublic/CommCare+Data+Export+Tool)  
to normalize the data if you are using the APis.

thanks,  
Cory

> **···**
>
> On Mon, Dec 21, 2015 at 12:53 AM, Hikesh Hasmukh wrote:
> 
> > When i try to get data from a repeat group, instead of returning an array,  
> > if it's one object it returns a single object instead of an array, for  
> > multiple objects it returns an array.
> > 
> > I think it should return an array in both cases in order to allow parsing  
> > of these objects.
> > 
> > --
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "CommCare Developers" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [commcare-developers+unsubscribe@googlegroups.com](mailto:commcare-developers+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Hikesh\_Hasmukh](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/h/f6c823/32.png) [@Hikesh\_Hasmukh](https://forum.dimagi.com/u/Hikesh_Hasmukh)\
**Post date:** [December 23, 2015, 8:26am UTC](https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529/3 "2015-12-23T08:26:29Z")

</div>

Hi Cory

We are using data forwarding, when there is a change or submission, data is  
forwarded to our web application and we use the CommCare API to parse the  
Json. In my perception, the data from a repeat group should be always in an  
array.  
We are building a parser for the json, and we need to know what kind of  
data to parse.

> **···**
>
> On Monday, December 21, 2015 at 8:33:40 PM UTC+2, Cory Zue wrote: \> \> Hi Hikesh, \> \> Can you clarify what you are referring to when you say "get data". \> \> Unfortunately our JSON format doesn't know at submission-time whether \> something is a repeat group or a regular group, which is why this behavior \> exists. I believe you should be able to use commcare export \> \> to normalize the data if you are using the APis. \> \> thanks, \> Cory \> \> On Mon, Dec 21, 2015 at 12:53 AM, Hikesh Hasmukh \<hikesh....@gmail.com \> wrote: \> \>\> When i try to get data from a repeat group, instead of returning an \>\> array, if it's one object it returns a single object instead of an array, \>\> for multiple objects it returns an array. \>\> \>\> I think it should return an array in both cases in order to allow parsing \>\> of these objects. \>\> \>\> -- \>\> \>\> --- \>\> You received this message because you are subscribed to the Google Groups \>\> "CommCare Developers" group. \>\> To unsubscribe from this group and stop receiving emails from it, send an \>\> email to commcare-developers+unsubscribe@googlegroups.com . \>\> For more options, visit https://groups.google.com/d/optout. \>\> \> \>

---

<div class="post-metadata">

**Author:** ![czue](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/czue/32/493_2.png) [@czue](https://forum.dimagi.com/u/czue)\
**Post date:** [December 23, 2015, 2:32pm UTC](https://forum.dimagi.com/t/getting-data-from-a-repeat-group/2529/4 "2015-12-23T14:32:45Z")

</div>

Hi Hikesh,

Understood. Yes, this is not possible to change right now due to the way  
that our XML to JSON parsing works. I'd recommend having your endpoint  
accommodate either the list or dict format.

thanks,  
Cory

> **···**
>
> On Wed, Dec 23, 2015 at 1:26 AM, Hikesh Hasmukh wrote:
> 
> > Hi Cory
> > 
> > We are using data forwarding, when there is a change or submission, data  
> > is forwarded to our web application and we use the CommCare API to parse  
> > the Json. In my perception, the data from a repeat group should be always  
> > in an array.  
> > We are building a parser for the json, and we need to know what kind of  
> > data to parse.
> > 
> > On Monday, December 21, 2015 at 8:33:40 PM UTC+2, Cory Zue wrote:
> > 
> > > Hi Hikesh,
> > > 
> > > Can you clarify what you are referring to when you say "get data".
> > > 
> > > Unfortunately our JSON format doesn't know at submission-time whether  
> > > something is a repeat group or a regular group, which is why this behavior  
> > > exists. I believe you should be able to use commcare export  
> > > [https://confluence.dimagi.com/display/commcarepublic/CommCare+Data+Export+Tool](https://confluence.dimagi.com/display/commcarepublic/CommCare+Data+Export+Tool)  
> > > to normalize the data if you are using the APis.
> > > 
> > > thanks,  
> > > Cory
> > > 
> > > On Mon, Dec 21, 2015 at 12:53 AM, Hikesh Hasmukh [hikesh....@gmail.com](mailto:hikesh....@gmail.com) wrote:
> > > 
> > > > When i try to get data from a repeat group, instead of returning an  
> > > > array, if it's one object it returns a single object instead of an array,  
> > > > for multiple objects it returns an array.
> > > > 
> > > > I think it should return an array in both cases in order to allow  
> > > > parsing of these objects.
> > > > 
> > > > --
> > > > 
> > > > * * *
> > > > 
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "CommCare Developers" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [commcare-developers+unsubscribe@googlegroups.com](mailto:commcare-developers+unsubscribe@googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "CommCare Developers" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [commcare-developers+unsubscribe@googlegroups.com](mailto:commcare-developers+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
