Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Can JOLT be used to decompose the value of the date time field in the following JSON

avatar
Rising Star

The JSON I have looks like this:

{     
"year":2018,   
"type":"N",  
"issued":"2018-10-17T20:16:00.000Z",   
"affectedFIR":"ZOA",   
"minimumFL":"000"
}

I'd like to figure out how to extract the value of issued, and decompose it into a JSON that looks like the following

{ 
"issued_year":"2018", 
"issued_month":"10", 
"issued_day":"17", 
"issued_hour":"20", 
"issued_minute":"16",
"issued_second":"00"
}
1 ACCEPTED SOLUTION

avatar
New Member

@David Sargrad,

JOLT cannot do that for you. You need to first get the value of the issued field in a flowfile attribute(using EvaluateJsonPath), then you can use expression language functions on that attribute to extract the year, month, date and so on from that attribute. You can use expression language in JOLT.

[
	{
		"operation": "default",
		"spec": {
			"issued_year": "${date_attribute:toNumber():format('YYYY')}",
			"issued_month": "${date_attribute:toNumber():format('MM')}"
		}
	}
]

Assuming that date_attribute is the attribute containing the evaluated date.

View solution in original post

2 REPLIES 2

avatar
New Member

@David Sargrad,

JOLT cannot do that for you. You need to first get the value of the issued field in a flowfile attribute(using EvaluateJsonPath), then you can use expression language functions on that attribute to extract the year, month, date and so on from that attribute. You can use expression language in JOLT.

[
	{
		"operation": "default",
		"spec": {
			"issued_year": "${date_attribute:toNumber():format('YYYY')}",
			"issued_month": "${date_attribute:toNumber():format('MM')}"
		}
	}
]

Assuming that date_attribute is the attribute containing the evaluated date.

avatar
New Member

This can be done by jolt like this:


[
{
"operation": "modify-overwrite-beta",
"spec": {
"issued_year": "=substring(@(1,issued),0,4)",
"issued_month": "=substring(@(1,issued),5,7)",
"issued_day": "=substring(@(1,issued),8,10)",
"issued_hour": "=substring(@(1,issued),11,13)",
"issued_minute": "=substring(@(1,issued),14,16)",
"issued_second": "=substring(@(1,issued),17,19)"
}
},
{
"operation": "shift",
"spec": {
"issued_year": "issued_year",
"issued_month": "issued_month",
"issued_day": "issued_day",
"issued_hour": "issued_hour",
"issued_minute": "issued_minute",
"issued_second": "issued_second"
}
}
]