Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 10-19-2018 10:23 AM
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"
}
Created 10-19-2018 11:41 AM
@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.
Created 10-19-2018 11:41 AM
@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.
Created 11-22-2021 02:56 AM
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"
}
}
]