Juan, What version of NiFi are you using? I tried with the latest master, using a GenerateFlowFile (where I set the attribute using the now() expression) into JoltTransformJSON with your spec above, and it works fine. Are you sure there's not a double-quote missing somewhere, or something extra in your EL expression?
Regards, Matt On Tue, Aug 7, 2018 at 11:03 AM Juan Sequeiros <[email protected]> wrote: > > Hello all, > > I am trying to "enrich" my json. > My problem happens when I try to give it a timestamp. > My requirement is to give it time in this format: > ${now():format("yyyy-MM-dd HH:mm",'Z')} > > So at the top level and every element of my json should have an entry called > > EX: > > "createTime":"2018-08-07 14:12" > > To do this I am creating an attribute "createTime" and setting it to > "${now():format("yyyy-MM-dd HH:mm",'Z')}" > > I then pass that to JoltTransform but it fails with: > > "Unable to unmarshal JSON to object" > > If I set my createTime attribute to hard code EX: "2018008-07 09:15" > Then it works. > > I've also tried setting my createTime toString but that does not help. > What helps is if I set my createTime to ${createTime:escapeJson()} > > But then elasticSearch does not like it since it has a "\n" in the end and > the elasticSearch index uses schema validation. > At this stage, we have not sprint planned to use records so when I ingest to > ES I am using PutElasticsearchHttp > > TLDR: > > JoltTransform errors out when I pass it an attribute set by calling the now() > function. > > My Jolt spec looks like this: > > Jolt Transformation DSL > Chain > [{ > "operation": "default", > "spec": { > "isVerified":"TRUE", > "recentResultDate" : "", > "createDate" : "${createDate}", > > "*":{ > "resultCode":"GREEN", > "resultDate":"${createDate}" > } > } > }] > -- > Juan Carlos Sequeiros
