Answers.Body: <p>Try this:</p>
  
  <pre><code>...
  'transformer' =&gt; function (EntryModel $entry) {
      return [
          'title' =&gt; $entry-&gt;title,
          'url' =&gt; $entry-&gt;url,
          'summary' =&gt; (string) $entry-&gt;summary
      ];
  },
  ...
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-29T01:10:17.143Z
Answers.Text: Hi Oliver - thank you, that did it! 
  I don't get it though. Was/is it something I did that I have to cast the summary as a string?
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-30T12:19:51.937Z
Answers.Text: Hey, I can't remember where I found this but no, you didn't do anything wrong. Rich text field just need to be cast as string to return the html as a string :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T14:34:51.220Z
Answers.LastActivityDate: 2015-11-28T14:34:51.220Z
Answers.UserDisplayName: Oli
Body: <p>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.</p>
  
  <p><strong>elementapi.php</strong></p>
  
  <pre><code>...
  'transformer' =&gt; function (EntryModel $entry) {
      return [
          'title' =&gt; $entry-&gt;title,
          'url' =&gt; $entry-&gt;url,
          'summary' =&gt; $entry-&gt;summary
      ];
  },
  ...
  </code></pre>
  
  <p>Here is the json I am getting back:</p>
  
  <pre><code>{"data":[{"title":"My Title","url":"http:\/\/local.mysite.dev\/section\/my-entry","summary":{}}
  </code></pre>
  
  <p><strong>EDIT/SOLUTION</strong></p>
  
  <p>Thank you again @Oliver!</p>
  
  <p>I wanted to update my post in the event someone else came across it. I am using <a href="https://github.com/janl/mustache.js" rel="nofollow">mustache.js</a> to render my html from the json that is getting output via the ElementAPI.</p>
  
  <p>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.</p>
  
  <p><strong>mustache</strong></p>
  
  <pre><code>&lt;p&gt;Title: {{title}}&lt;/p&gt;
  &lt;p&gt;URL: {{url}}&lt;/p&gt;
  {{{ summary }}}
  </code></pre>
  
  <p>Otherwise you will end up with something that looks like this:</p>
  
  <pre><code>Title: My Title
  URL: www.mysite.com
  &lt;p&gt;This is my summary&lt;/p&gt;
  </code></pre>
  
Tags: <plugin-elementapi>
Title: Why is the summary and body returning an empty object using the Element API?
ThreadText: # Why is the summary and body returning an empty object using the Element API?
  
  (Asked by: username_0 on 2015-11-23)
  
  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' => function (EntryModel $entry) {
      return [
          'title' => $entry->title,
          'url' => $entry->url,
          'summary' => $entry->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](https://github.com/janl/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**
  
  ```
  <p>Title: {{title}}</p>
  <p>URL: {{url}}</p>
  {{{ summary }}}
  
  ```
  
  Otherwise you will end up with something that looks like this:
  
  ```
  Title: My Title
  URL: www.mysite.com
  <p>This is my summary</p>
  
  ```
  
  **Tags:** plugin-elementapi
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-11-28. Score: 6 | Accepted answer
  
  Try this:
  
  ```
  ...
  'transformer' => function (EntryModel $entry) {
      return [
          'title' => $entry->title,
          'url' => $entry->url,
          'summary' => (string) $entry->summary
      ];
  },
  ...
  
  ```
  
  > **Comments:**
  > **username_0**: Hi Oliver - thank you, that did it!  I don't get it though. Was/is it something I did that I have to cast the summary as a string?  
  > **username_1**: Hey, I can't remember where I found this but no, you didn't do anything wrong. Rich text field just need to be cast as string to return the html as a string :)  
  
  ---
  
  