Element API: Remove additional set of square brackets from JSON-String We're currently having an Android-App access some of the entries of our Craft-based website. We are currently still using a self built API, and for easier creation of new API-Calls we are trying to migrate over to Pixel &amp; Tonic's Element API plugin.

The entries (or the blocks of a Matrix-field of that entry, to be more precise) are accessed like so:

'api/alloverlist' =&gt; function() { // GET ALLOVER-CHALLENGES
        return [
            'elementType' =&gt; ElementType::Entry,
            'criteria' =&gt; [
                'section' =&gt; 'challenges',
                ],
            'paginate' =&gt; false,
            'first' =&gt; true,
            'transformer' =&gt; function(EntryModel $entry){

                $allOverChallenges = [];
                foreach ($entry-&gt;allOverChallenge as $challenge){
                    $allOverChallenges[] = [
                        'elementId' =&gt; $challenge-&gt;id,
                        'field_allOverChallenge_allOverName' =&gt; $challenge-&gt;allOverName,
                    ];
                }

                return [
                    $allOverChallenges
                ];
            },
        ];
    },


The returned JSON-String has the following appearance:

[
[
    {
        "elementId": "1298",
        "field_allOverChallenge_allOverName": "Dein schönster Sonnenaufgang"
    },
    {
        "elementId": "1310",
        "field_allOverChallenge_allOverName": "AllOverChallenge2"
    },
    {
        "elementId": "1318",
        "field_allOverChallenge_allOverName": "Allover Challenge 3"
    }
]
]


However, the Android-App accepts the JSON-String just with single square-brackets, like so:

[
   {
     "key":"value",
      ...
   },

   {
     "key":"value",
      ...
   }
]


For the sake of not having to change the existing Android-App, is it somehow possible to remove the additional square brackets? 

Thanks.
Though I don't know the Element API, have you tried

    return $allOverChallenges;


instead of

    return [
        $allOverChallenges
    ];


It looks like you are simply adding these brackets (Array) on the return.