Not really sure how to select this data

Dec 5, 2012 at 5:02 PM

I have the following JSON:

 

{
   "PID":"1234",
   "c_InfoCol":[
      {
         "c_State":"AL", "c_LicLabel":"Lic", "c_TypeCol":[
            {
               "LicType":null,
               "c_SubTypeCol":[
                  { "c_TypeID":"1", "Description":"AL", "Hours":5.0, "Units":5.0, "Price":5.0, "c_Exclusive":0.0},
                  { "c_TypeID":"2", "Description":"AL", "Hours":3.0, "Units":3.0, "Price":3.0, "c_Exclusive":0.0}
               ]
            }
         ]
      },
      {
         "c_State":"CT",
         "c_LicLabel":"Lic",
         "c_TypeCol":[
            {
               "LicType":"LH Lic",
               "c_SubTypeCol":[
                  { "c_TypeID":"3", "Description":"CT", "Hours":7.0, "Units":1.0, "Price":3.8, "c_Exclusive":0.0},
                  { "c_TypeID":"4", "Description":"CT", "Hours":1.0, "Units":1.0, "Price":3.8, "c_Exclusive":0.0}
               ]
            },
            {
               "LicType":"PC Lic",
               "c_SubTypeCol":[
                  { "c_TypeID":"5", "Description":"CT", "Hours":7.0, "Units":1.0, "Price":3.8, "c_Exclusive":0.0},
                  { "c_TypeID":"6", "Description":"CT", "Hours":1.0, "Units":1.0, "Price":3.8, "c_Exclusive":0.0}
               ]
            }
         ]
      }
   ]
}

 

How would I select all c_SubTypeCol that has the Description 'CT'?

Dec 5, 2012 at 10:06 PM

Nevrmind, I decided to use SpahQL instead since I am not very familiar with LinQ.

Coordinator
Dec 21, 2012 at 6:52 AM
Edited Dec 21, 2012 at 7:03 AM

use selectMany.

var json = {"PID":.....}
var query = Enumerable.from(json.c_InfoCol)
    .selectMany("$.c_TypeCol")
    .selectMany("$.c_SubTypeCol")
    .where("$.Description == 'CT'");
 
query.writeLine();