<p>I just came across this problem and solved it by editing the <strong>JsonExpandService.php</strong> file (located in craft/plugins/jsonexpand/services/) in two places.</p>

<p>Change line 101 from this:</p>

<pre><code>$relatedArray[$subHandle] = $subValue;
</code></pre>

<p>To this:</p>

<pre><code>if($subField['type'] == "RichText") {
    // Rich Text field values need to be converted to a string
    $relatedArray[$subHandle] = (string)$subValue;
} else {
    $relatedArray[$subHandle] = $subValue;
}
</code></pre>

<p>And change line 115 from this:</p>

<pre><code>$entryData[$handle] = $value;
</code></pre>

<p>To this:</p>

<pre><code>if($field['type'] == "RichText") {
    $entryData[$handle] = (string)$value;
} else {
    $entryData[$handle] = $value;
}
</code></pre>

<p>This fixed Rich Text fields coming through as empty objects for me.</p>

<p>This plugin hasn't been updated in 3 years, so Craft probably changed something about how Rich Text fields are outputted and the plugin never adjusted. Just a guess.</p>

CC BY-SA 3.0
2017-09-21T15:41:36.727Z
2017-09-21T15:41:36.727Z
Luke Peters
<p>Is anybody using the <a href="https://github.com/familiar-studio/craft-json-expand" rel="nofollow">json_expand plugin</a> for API functionality?
For the entry type Rich Text Field its just returning an empty object.</p>

<p>This is my json_expand endpoint:</p>

<pre><code>{% header "Content-Type: application/json" %}
{% set utensils = craft.entries.section('utensils').find('') %}
{{ utensils | json_expand | raw  }}
</code></pre>

<p>It's returning everything except that Rich Text field which just returns this:</p>

<pre><code>"utensil_textbox": {}
</code></pre>

CC BY-SA 3.0
2016-02-17T17:35:47.160Z
Total shot in the dark, but scroll to the bottom of [this thread](http://craftcms.stackexchange.com/questions/12515/why-is-the-summary-and-body-returning-an-empty-object-using-the-element-api/12577) I was having a similar problem with using the ElementAPI + rich text field.
Damon
CC BY-SA 3.0
2016-02-17T17:37:35.063Z
Never used JSON Expand plugin, but try this:  `{{ utensils.getRawContent() | json_expand | raw  }}`
Brad Bell
<plugin-jsonexpand>
Rich Text Field is returning an empty object over api of plugin json_expand
# Rich Text Field is returning an empty object over api of plugin json_expand

(Asked by: username_0 on 2016-02-17)

Is anybody using the json_expand plugin for API functionality?
For the entry type Rich Text Field its just returning an empty object.
This is my json_expand endpoint:
{% header "Content-Type: application/json" %}
{% set utensils = craft.entries.section('utensils').find('') %}
{{ utensils | json_expand | raw  }}

It's returning everything except that Rich Text field which just returns this:
"utensil_textbox": {}

**Tags:** plugin-jsonexpand

> **Comments:**
> **username_1**: Total shot in the dark, but scroll to the bottom of [this thread](http://craftcms.stackexchange.com/questions/12515/why-is-the-summary-and-body-returning-an-empty-object-using-the-element-api/12577) I was having a similar problem with using the ElementAPI + rich text field.  
> **username_2**: Never used JSON Expand plugin, but try this:  `{{ utensils.getRawContent() | json_expand | raw  }}`  

---

## 1 answers

### Answer by username_3 on 2017-09-21. Score: 3

I just came across this problem and solved it by editing the JsonExpandService.php file (located in craft/plugins/jsonexpand/services/) in two places.
Change line 101 from this:
$relatedArray[$subHandle] = $subValue;

To this:
if($subField['type'] == "RichText") {
    // Rich Text field values need to be converted to a string
    $relatedArray[$subHandle] = (string)$subValue;
} else {
    $relatedArray[$subHandle] = $subValue;
}

And change line 115 from this:
$entryData[$handle] = $value;

To this:
if($field['type'] == "RichText") {
    $entryData[$handle] = (string)$value;
} else {
    $entryData[$handle] = $value;
}

This fixed Rich Text fields coming through as empty objects for me.
This plugin hasn't been updated in 3 years, so Craft probably changed something about how Rich Text fields are outputted and the plugin never adjusted. Just a guess.


---

