开发者

How can I generate XML from the JSON Data using c#?

开发者 https://www.devze.com 2023-01-17 16:31 出处:网络
I have the JSON data something like below: { \"#data\": [ { \"nid\": \"814\", \"type\": \"resource\", \"language\": \"\",

I have the JSON data something like below:

{
    "#data": [
        {
            "nid": "814",
            "type": "resource",
            "language": "",
            "uid": "125",
            "status": "1",
            "title": "title 1",
            "description": "description 1",
            "rating": "5",
            "picture": "" 
        },
        {
            "nid": "814",
            "type": "resource",
            "language": "",
            "uid": "125",
            "status": "1",
            "title": "title 2",
            "description": "description 2",
            "rating": "3.5",
            "picture": "" 
        }
    ]
}

I need to build XML out of this something like below:

<node title="title 1" type="resource" rating="5">
        <description>description 1</description>
</node>
<node title="title 2" type="resource" rating="3.5">
 <description>description 2</description>
</node>

I don't want to deserialize开发者_运维问答 the JSON data, but I need to fetch only few elements and build the XML object. Can anyone help me on this?


Deserialize it into a c# object then xml serialize it. Easiest way


You'll need to deserialize it, unless you want to do some ugly string parsing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号