# How to read the date from multiline Json and covert the string to date

**URL:** <https://discuss.elastic.co/t/how-to-read-the-date-from-multiline-json-and-covert-the-string-to-date/104171>\
**Category:** Logstash\
**Created:** [October 17, 2017, 5:16am UTC](https://discuss.elastic.co/t/how-to-read-the-date-from-multiline-json-and-covert-the-string-to-date/104171 "2017-10-17T05:16:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vignesh\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vignesh_kumar/32/41866_2.png) [@Vignesh\_Kumar](https://discuss.elastic.co/u/Vignesh_Kumar)\
**Post date:** [October 17, 2017, 5:16am UTC](https://discuss.elastic.co/t/how-to-read-the-date-from-multiline-json-and-covert-the-string-to-date/104171/1 "2017-10-17T05:16:10Z")

</div>

Have the following JSON object where i need to get the element and convert the string to date and traverse through the JSON,

{  
"Client": {  
"Client Name": "KM Jons",  
"Portfolio": "Food and Beverage",  
"ProcessName": "Sales"  
},  
"Sales":[  
{  
"StartTime": "20170926105415",  
"Quantity": "100",  
"location": "Seoul"  
},  
{  
"StartTime": "20170926105418",  
"Quantity": "100",  
"location": "Singapore"  
}  
]  
}

Have tried the following JSON config with ruby code as below,  
input {  
file {  
type =\> "json"  
path =\> "C:/ELK/data/Recordings/\*.json"  
start\_position =\> beginning  
codec =\> multiline {  
pattern =\> "^{"  
negate =\> "true"  
what =\> "previous"  
max\_lines =\> 30000  
}  
}  
}  
filter{  
mutate {  
replace =\> { "message" =\> "%{message}}" }  
gsub =\> ['message','\n','']  
}

```
json { 
source => "message" 
remove_field => ["message"]
target => "wtfyo"
}

ruby {
code => "
event.get('[Sales]').each {|hash| event.set(hash['key'],hash['value'])}
"
}

```

}

output {  
elasticsearch {  
index =\> "test15"  
}  
stdout { codec =\> rubydebug }  
}

Please help me to fix this and want to get the output as below,  
{  
"Client": {  
"Client Name": "KM Jons",  
"Portfolio": "Food and Beverage",  
"ProcessName": "Sales"  
},  
"Sales":[  
{  
"StartTime": 2017-09-26T10:54:15.000Z,  
"Quantity": "100",  
"location": "Seoul"  
},  
{  
"StartTime": 2017-09-26T10:54:18.000Z,  
"Quantity": "100",  
"location": "Singapore"  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 14, 2017, 5:16am UTC](https://discuss.elastic.co/t/how-to-read-the-date-from-multiline-json-and-covert-the-string-to-date/104171/2 "2017-11-14T05:16:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
