JsonDeserializer and YamlDeserializer incorrectly checking data type
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3541580. --> Reported by: [michaellander](https://www.drupal.org/user/636494) Related to !834 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The <code>json_as_string</code> and <code>yaml_as_string</code> data types were added as types that should be decoded. The naming on them is confusing and I think they may actually be unnecessary. I believe if we make the following changes it would work better. </p> <p><code>\Drupal\ai\Plugin\AiDataTypeConverter\JsonDeserializer::appliesToDataType()</code></p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #007700">if (</span><span style="color: #0000BB">$data_type </span><span style="color: #007700">=== </span><span style="color: #DD0000">'string'</span><span style="color: #007700">) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">AppliesResult</span><span style="color: #007700">::</span><span style="color: #0000BB">notApplicable</span><span style="color: #007700">(</span><span style="color: #DD0000">'"string" data types should not be parsed as json'</span><span style="color: #007700">);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">AppliesResult</span><span style="color: #007700">::</span><span style="color: #0000BB">applicable</span><span style="color: #007700">();<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p><code>\Drupal\ai\Plugin\AiDataTypeConverter\YamlDeserializer::appliesToDataType()</code></p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #007700">if (</span><span style="color: #0000BB">$data_type </span><span style="color: #007700">!== </span><span style="color: #DD0000">'string'</span><span style="color: #007700">) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">AppliesResult</span><span style="color: #007700">::</span><span style="color: #0000BB">notApplicable</span><span style="color: #007700">(</span><span style="color: #DD0000">'"string" data types should not be parsed as yaml'</span><span style="color: #007700">);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">AppliesResult</span><span style="color: #007700">::</span><span style="color: #0000BB">applicable</span><span style="color: #007700">();<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>See above and remove 'json_as_string' and 'yaml_as_string' data types.</p>
issue