Why is the summary and body returning an empty object using the Element API? I'm not sure what I'm missing, but I'm getting an empty object back from the Element API for the summary and/or body for any given entry.

elementapi.php

...
'transformer' =&gt; function (EntryModel $entry) {
    return [
        'title' =&gt; $entry-&gt;title,
        'url' =&gt; $entry-&gt;url,
        'summary' =&gt; $entry-&gt;summary
    ];
},
...


Here is the json I am getting back:

{"data":[{"title":"My Title","url":"http:\/\/local.mysite.dev\/section\/my-entry","summary":{}}


EDIT/SOLUTION

Thank you again @Oliver!

I wanted to update my post in the event someone else came across it. I am using mustache.js to render my html from the json that is getting output via the ElementAPI.

By casting the summary as a string, you will need to tell mustache to parse the html by using three curly-brackets instead of the usual two.

mustache

&lt;p&gt;Title: {{title}}&lt;/p&gt;
&lt;p&gt;URL: {{url}}&lt;/p&gt;
{{{ summary }}}


Otherwise you will end up with something that looks like this:

Title: My Title
URL: www.mysite.com
&lt;p&gt;This is my summary&lt;/p&gt;
Try this:

...
'transformer' =&gt; function (EntryModel $entry) {
    return [
        'title' =&gt; $entry-&gt;title,
        'url' =&gt; $entry-&gt;url,
        'summary' =&gt; (string) $entry-&gt;summary
    ];
},
...