无法从json文件中删除转义字符

时间:2015-04-13 20:52:38

标签: c# xml json.net

从xml解析json文件时,我无法从中删除Unicode字符(如\ r \ n)。帮我解决这个问题。谢谢。

string JsonText = JsonConvert.SerializeXmlNode(doc);            
JObject j = JObject.Parse(JsonText);

以下是json文件的示例:

"brief_summary": {
  "textblock": "\r\n      Comparison of efficacy and safety of Azelaic Acid 15% gel with its vehicle in male and\r\n      female patients with mild to moderate acne.\r\n\r\n      Qualified subjects will apply the gel to their face twice a day for a period of 12 weeks.\r\n      Subjects will be required to return to the doctor's office for up to 5 visits.\r\n    "
},
"detailed_description": {
  "textblock": "\r\n      Acne is a common inflammatory skin condition characterized by skin eruptions around hair\r\n      follicles. People with acne can have pustules (zits or pimples), papules, whiteheads or\r\n      blackheads, nodules, and redness of the skin. Acne usually involves the face and shoulders,\r\n      but can also involve the chest, arms, and legs. The purpose of this study is to evaluate the\r\n      safety and effectiveness of an investigational gel containing active medication compared to\r\n      the same gel without any active medication (placebo or vehicle) in subjects with mild to\r\n      moderate facial acne.\r\n\r\n      This study has initially been posted by Berlex, Inc. Berlex, Inc. has been renamed to Bayer\r\n      HealthCare Pharmaceuticals, Inc.\r\n\r\n      Intendis Inc., a Bayer HealthCare company, is the sponsor of the trial.\r\n    "
},

这是相应的xml被转换

 <brief_summary><textblock> PRIMARY: To assess the safety of nimodipine in the treatment of HIV-Associated Motor / Cognitive Complex (formerly AIDS dementia complex). To assess the systemic or central nervous system toxicities (e.g., rash, headache, gastrointestinal symptoms, nausea, dyspnea, muscle pain or cramp, acne) of nimodipine. SECONDARY: To assess the efficacy of nimodipine in stabilizing the progression of HIV-Associated Motor / Cognitive Complex by improvement in neuropsychological test performance, peripheral neuropathy, or other neurologic manifestations. HIV-infected patients may develop a condition known as HIV-Associated Motor / Cognitive Complex (also known as AIDS dementia complex) that causes damage to the nervous system, particularly the brain and spinal cord. Evidence exists that nimodipine protects nerve cells in culture from injury by HIV. Although nimodipine has been used in patients with other neurological problems, its safety and effectiveness in halting the progression of HIV-Associated Motor / Cognitive Complex is not yet known. </textblock></brief_summary>
<detailed_description><textblock> HIV-infected patients may develop a condition known as HIV-Associated Motor / Cognitive Complex (also known as AIDS dementia complex) that causes damage to the nervous system, particularly the brain and spinal cord. Evidence exists that nimodipine protects nerve cells in culture from injury by HIV. Although nimodipine has been used in patients with other neurological problems, its safety and effectiveness in halting the progression of HIV-Associated Motor / Cognitive Complex is not yet known. Forty patients currently taking zidovudine (AZT) or any other approved antiretroviral agent will be randomized to one of three treatment arms: high-dose nimodipine, low-dose nimodipine, or placebo. Additionally, six patients who are intolerant to standard antiretroviral therapy will be randomized to receive high- or low-dose nimodipine. Nimodipine is administered by mouth concurrently with patients' prestudy dose of antiretroviral agent. Treatment is given for 16 weeks, and patients are followed every 4 weeks. As an option, all patients may receive an additional 16 weeks of low-dose nimodipine. </textblock>

1 个答案:

答案 0 :(得分:0)

修改输出:

string json = j.ToString(Formatting.None);

或尝试JsonConvert.SerializeObject