JOLT JSON阵列

问题描述:

我试图将字符串转换为与我的规格文件定期string.but的阵列,它回来了作为阵列始终JOLT JSON阵列

样品输入(来自ES)

{ 
    ... 
    "hits": { 
     "total": 1, 
     "max_score": 1.4818809, 
     "hits": [ 
      { 
       "_index": "twitter", 
       "_type": "tweet", 
       "_id": "1", 
       "_score": 1.4818809, 
       "_source": { 
        "user": "test", 
        "message": "some message with the number 1", 
        "date": "2009-11-15T14:12:12", 
        "likes": 1 
       }, 
       "highlight": { 
        "message": [ 
         "some message with the <em>number</em> <em>1</em>" 
        ] 
       } 
      } 
     ] 
    } 
} 

SPEC文件

[ 
    { 
    "operation": "shift", 
    "spec": { 
     "took": "took", 
     "hits": { 
     "total": "total_hits", 
     "hits": { 
      "*": { 
      "_source": { 
       "user": "Response[&2].firstName" 
      }, 
      "highlight": { 
       "message": ["Response[&2].h_message"] 
      } 
      } 
     } 
     } 
    } 
} 
] 

输出:

{ 
    "Response" : [ { 
    "firstName" : "test", 
    "h_message" : [ "some message with the <em>number</em> <em>1</em>" ] 
    } ], 
    "total_hits" : 1 
} 

正如你可以看到,“h_message”是走出来作为array.I想获得是一个字符串/值

"h_message" : [ "some message with the <em>number</em> <em>1</em>" ] 

解决它

[ 
    { 
    "operation": "shift", 
    "spec": { 
     "took": "took", 
     "hits": { 
     "total": "total_hits", 
     "hits": { 
      "*": { 
      "_source": { 
       "user": "Response[&2].firstName" 
      }, 
      "highlight": { 
       "message": { 
       "*": "Response[&0].h_message" 
       } 
      } 
      } 
     } 
     } 
    } 
} 
]