我可以帮您将JSON字符串转换为XML格式。 1)我的JSON字符串是:
[
{
"QuizTitle":"asdf",
"QuizImage":"",
"QuizCategory":"0",
"QuizTags":"asdf",
"question":[
[
{
"QuestionType":"1",
"QuestionTitle":"asdf",
"questionOption":[
{
"QuestionOptionValue":"sdf",
"QuestionOptionIsRight":"0"
},
{
"QuestionOptionValue":"asdf",
"QuestionOptionIsRight":"1"
}
]
}
],
[
{
"QuestionType":"2",
"QuestionTitle":"sdfdsf",
"questionOption":[
{
"QuestionOptionValue":"asdf",
"QuestionOptionIsRight":"0"
},
{
"QuestionOptionValue":"asdf",
"QuestionOptionIsRight":"1"
}
]
}
]
]
}
]
2) 我的C#代码是:
XmlDocument doc = JsonConvert.DeserializeXmlNode(str);
出现以下错误:
我尝试对Error:--XmlNodeConverter can only convert JSON that begins with an object.
json
进行了一些小的修改,例如删除问题元素中的 []
,但没有起作用。
JsonConvert.DeserializeXmlNode(str,"root");
吗? - Mohit S