I have a json string containing encoded HTML as below which I get after doing a Shopify Liquid escape. I am trying to decode the internal HTML and deserialize this string into a JObject.
{
"testId": 494254,
"languageIdentifier": "en_us",
"overview":"<p style="margin: 0px;"><span>Overview'ff' Test</span></p>",
"responsibilities":"<p style="margin: 0px;"><span>Responsibilities</span></p>",
"qualifications":"<p style="margin: 0px;"><span>Qualifications</span></p>",
"guidance":"z_used_Guidance Test",
"additionalDetailsForInternalCandidates":"<p style="margin: 0px;"><span>Additional Details</span></p>",
"requisitionNotes":"Requisition Notes"
}
The actual html is:
{
"testId": 494254,
"languageIdentifier": "en_us",
"overview": "<p style=\"margin: 0px;\"><span>Overview'ff' Test</span></p>"
"responsibilities": "<p style=\"margin: 0px;\"><span>Responsibilities</span></p>"
"qualifications": "<p style=\"margin: 0px;\"><span>Qualifications</span></p>"
"additionalDetailsForInternalCandidates":"<p style=\"margin: 0px;\"><span>Additional Details</span></p>",
"guidance":"z_used_Guidance Test",
"requisitionNotes":"Requisition Notes"
}
However, when I try to decode and deserialize, it is failing. My code is:
string test = "{\r\n\t\"testId\": 494254,\r\n\t\"languageIdentifier\": \"en_us\",\r\n\t\"overview\":\"<p style="margin: 0px;"><span>Overview'ff' Test</span></p>\",\t\r\n\t\"responsibilities\":\"<p style="margin: 0px;"><span>Responsibilities</span></p>\",\r\n\t\"qualifications\":\"<p style="margin: 0px;"><span>Qualifications</span></p>\",\r\n\t\"guidance\":\"z_used_Guidance Test\",\r\n\t\"additionalDetailsForInternalCandidates\":\"<p style="margin: 0px;"><span>Additional Details</span></p>\",\r\n\t\"requisitionNotes\":\"Requisition Notes\"}";
var jsonString = HttpUtility.HtmlDecode(test);
var objectjson = JsonConvert.DeserializeObject<JObject>(jsonString);
However, I get this error:
'After parsing a value an unexpected character was encountered: m. Path 'overview', line 4, position 23.'
Can anyone help me in decoding an encoded HTML and deserialize it into JObject? I want it as a decoded html string like the original input
{
"testId": 494254,
"languageIdentifier": "en_us",
"overview": "<p style=\"margin: 0px;\"><span>Overview'ff' Test</span></p>",
"responsibilities": "<p style=\"margin: 0px;\"><span>Responsibilities</span></p>",
"qualifications": "<p style=\"margin: 0px;\"><span>Qualifications</span></p>",
"additionalDetailsForInternalCandidates":"<p style=\"margin: 0px;\"><span>Additional Details</span></p>",
"guidance":"z_used_Guidance Test",
"requisitionNotes":"Requisition Notes"
}
Thanks in advance.
Overview 'Test'
", "responsibilities":"Responsibilities
", "qualifications":"Qualifications
", "guidance":"z_used_Guidance Test", "additionalDetailsForInternalCandidates":"Additional Details
", "requisitionNotes":"Requisition Notes"} – Na.B Jul 08 '20 at 09:45Overview Test
. We are doing an escape using Shopify Liquid Templates and after doing the escape we get this string. And there is no scope of unescape in Shopify Liquid. So we have to do manually. – Na.B Jul 08 '20 at 09:50