C# 使用C获取基于条件的json child#

C# 使用C获取基于条件的json child#,c#,json,C#,Json,上面是我必须处理的json 如果我从他们的数据库中发送/搜索一个值(105),我需要获取它的所有childs json数据(107108109110)。请帮助我在C#中设计一些类,通过序列化将json数据作为字符串读入,然后使用LINQ通过Items属性进行选择 [ { "Text": "Topaz Building", "Value": "101", "Expanded": false, "Items": [

上面是我必须处理的json

如果我从他们的数据库中发送/搜索一个值(105),我需要获取它的所有childs json数据(107108109110)。请帮助我

在C#中设计一些类,通过序列化将json数据作为字符串读入,然后使用LINQ通过Items属性进行选择

[
    {
        "Text": "Topaz Building",
        "Value": "101",
        "Expanded": false,
        "Items": [
            {
                "Text": "Floor1",
                "Value": "102",
                "Expanded": false,
                "Items": [
                    {
                        "Text": "Room1",
                        "Value": "105",
                        "Expanded": false,
                        "Items": [
                            {
                                "Text": "Cab1",
                                "Value": "107",
                                "Expanded": false
                            },
                            {
                                "Text": "Cab2",
                                "Value": "108",
                                "Expanded": false,
                                "Items": [
                                    {
                                        "Text": "Sub1",
                                        "Value": "109",
                                        "Expanded": false
                                    },
                                    {
                                        "Text": "Sub2",
                                        "Value": "110",
                                        "Expanded": false
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "Text": "Room2",
                        "Value": "106",
                        "Expanded": false
                    }
                ]
            },
            {
                "Text": "Floor2",
                "Value": "103",
                "Expanded": false,
                "Items": [
                    {
                        "Text": "Room1",
                        "Value": "111",
                        "Expanded": false
                    },
                    {
                        "Text": "Room2",
                        "Value": "112",
                        "Expanded": false,
                        "Items": [
                            {
                                "Text": "Cab1",
                                "Value": "113",
                                "Expanded": false,
                                "Items": [
                                    {
                                        "Text": "Sub1",
                                        "Value": "115",
                                        "Expanded": false
                                    },
                                    {
                                        "Text": "Sub2",
                                        "Value": "116",
                                        "Expanded": false
                                    }
                                ]
                            },
                            {
                                "Text": "Cab2",
                                "Value": "114",
                                "Expanded": false
                            }
                        ]
                    }
                ]
            },
            {
                "Text": "Floor3",
                "Value": "104",
                "Expanded": false
            }
        ]
    }
]

但我不想这样,我想我发送一个值,基于我必须得到它的childs考虑到你在你的问题中指定了C,我提供了一个C的答案。我想你可能会问一个不同的问题,所以在这种情况下,我建议你把你的问题说得更清楚。c#only,请告诉我如何解析json和查询json格式我清楚地告诉你,我得到的是json格式上面我想要的是查询json格式。我发送一个子值作为输入,我想要它的childs
using System;
using System.Runtime.Serialization;

namespace YourNamespace
{
    [Serializable]
    [DataContract]
    public class Data
    {
        [DataMember(Name = "Text"]
        public string Text{get;set;}

        [DataMember(Name = "Value"]
        public string Value{get;set;}

        [DataMember(Name = "Expanded"]
        public bool Expanded{get;set;}

        [DataMember(Name = "Items"]
        public Data[] Items{get;set;}
    }
}