I’m using json_encode(); on this array and the double quotes within <sup id="1"> are breaking it… can anyone explain why? shouldn’t this function be built to protect this data automatically?
array(
'Content' => array(
'GUID' => '7dbbfdfd-d1b2-46bd-934f-0730bcf55495',
'Publish_Date' => '2012-04-10 19:28:13',
'Content_Type' => 'Header',
'Content_Body_Type' => 'OVERVIEW',
'Paperless' => 'REQUIRED_EDELIVERY',
'Status' => 'Proof',
'Body' => htmlentities('<h3>This is a subhead</h3>
<p>This is sample content<sup id="1">1 </sup>with variables: <Outside_Sales><Support_Services_Program></p>
<p>Bulleted list:</p>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
<p>more text</p>'),
I used http://jsonlint.com to determine the problem
This is likely a double escaping issue since you are using
htmlentities()thenjson_encode().Just use
json_encode().Generally speaking, it’s best to only escape during output. That way you can maintain raw data.