值作为列表出现.. JMESPath 中的每个单元格需要一个值

时间:2021-03-03 21:35:59

标签: jmespath

我有一个嵌套的 json。我想提取以下值 Institute_id,investor_id,consultant_id .我似乎无法正确提取它。请参阅下文。有人可以帮忙吗。

{
   instituition_id : 112,
   name : 'abc',
   invest_funds: [
     { 
          investor_id : 20,
          name: 'fake',
          consultants:[
             {
                consultant_id: 10,
                name: 'xyz', 
                consultant_offices: [
                   {
                       consultant_office_id : 1,
                       name: 'jkl',
                       consultant_contants : [
                         {
                            consultant_contact_id: 15,
                             another_id: 211,
                             asset_classes:[
                             {
                               val1: 'abc',
                               val2: 311,
                               val3: 'dfsd',
                               val4: 'fghfhg'
                               },
                             {
                               val1: 'def',
                               val2: 301,
                               val3: 'sedr',
                               val4: 'kugg'
                               },
                        
                           ]
                         }
                      ]
                   }
               ]
      },
      {
         consultant_id: 14,
         name: 'pqr',
         consultant_offices: [
      ]
    }
 ]
},
    { 
          investor_id : 28,
          name: 'fake1',
          consultants:[
             {
                consultant_id: 30,
                name: 'xyz1', 
                consultant_offices: [
                    
                 ]
              }
          ]
       }
     ]
   }

我正在创建映射。

    {"unnest":true, "path":"invest_funds[?consultants]"},
    {"name":"institution_id", "path":"institution_id", "absolute": true},
    {"name":"investor_id", "path":"investor_id"},
    {"name":"consultant_id", "path":"consultants[?consultant_id]"}

我的结果:

institution_id  investor_id consultant_id
112                    20                       [10, 14]
112                    28                           [30]  

想要

institution_id  investor_id consultant_id
112                    20                       10
112                    20                       14
112                    28                       30

0 个答案:

没有答案
相关问题