2017-07-19 109 views
0

我試圖將字符串轉換爲與我的規格文件定期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>" ] 

回答

0

解決它

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