选择query以使用sqlserver获取json对象的一部分

dwbf0jvd  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(157)

我有下面的json对象。我需要编写一个select查询,通过避免run对象来获取json对象。例如:从表中选择jsondata(但是jsondata应该没有run对象)。

{
  "Model": [
    {
  "ModelName": "Test Model",    
  "Object": [
     {
       "ID": 1,
       "Name": "ABC",
       "Task" : [
         {
            "TaskID" : 1222,
            "Name": "TaskA",
            "Run" :[
             {
                "RunID": 10,
                "RunName": "Test Run"
             },
             {
                "RunID": 11,
                "RunName": "Test Run1"
             },
            ]
         },
         {
            TaskID : 154,
            Name: "TaskB"
            "Run" :[
               {
                "RunID": 100,
                "RunName": "Test Run100"
               },
               {
                "RunID": 111,
                "RunName": "Test Run111"
               },
            ]
         },
         {
            TaskID : 154,
            Name: "TaskB",
            "Run" :[
               {
                "RunID": 1003,
                "RunName": "Test Run1003"
               },
               {
                "RunID": 1113,
                "RunName": "Test Run1131"
               },
            ]
         }
       ]
         }
       ]
     },
     {
       "ID": 11,
       "Name": "ABCD",
       "Task" : [
         {
            TaskID : 222,
            Name: "TaskX",
            "Run" :[
               {
                "RunID": 1001,
                "RunName": "Test Run1001"
               },
               {
                "RunID": 1111,
                "RunName": "Test Run1111"
               },
            ]
         },
         {
           TaskID : 234,
           Name: "TaskY",
           "Run" :[
               {
                "RunID": 1002,
                "RunName": "Test Run1002"
               },
               {
                "RunID": 1112,
                "RunName": "Test Run1112"
               },
            ]
         }
       ]
    },         
   ]  
 }]}

预期输出应为以下值。只需要避免运行对象。tablea和column name中的json对象是jsondata

{
  "Model": [
    {
  "ModelName": "Test Model",    
  "Object": [
     {
       "ID": 1,
       "Name": "ABC",
       "Task" : [
         {
            TaskID : 1222,
            Name: "TaskA"
         },
         {
            TaskID : 154,
            Name: "TaskB"
         }
       ]
     },
     {
       "ID": 11,
       "Name": "ABCD",
       "Task" : [
         {
            TaskID : 222,
            Name: "TaskX"
         },
         {
           TaskID : 234,
           Name: "TaskY"
         }
       ]
    },         
 ]  
 }]}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题