<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Problem with JoltTransformation in NIFI in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380847#M244186</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105912"&gt;@MWM&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;There are couple of issues I noticed regarding the input json and the spec:&lt;/P&gt;&lt;P&gt;1- Regarding the "paycheck" value "3456,98" , I noticed there is coma (,) is that correct? if that is the case , Im not sure the conversion will work in this case.&amp;nbsp; You have to probably replace the coma with dot (.) and then convert toDouble. It takes few steps to do this in jolt since there is no string replace function using split, join as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;,
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      ....
      "paycheckArray": "=split('[,]',@(1,paycheck))",
      "paycheckJoin": "=join('.',@(1,paycheckArray))",
      "paycheck": "=toDouble(@(1,paycheckJoin))",
      ....
    }
}
,
  {
    "operation": "remove",
    "spec": {
      "paycheckArray": "",
      "paycheckJoin": ""
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- Regarding the boolean value "isOfAge" , since you have moved it under person object, the spec would as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "operation": "modify-overwrite-beta",
    "spec": {
      ...
      "person": {
        "isOfAge": "=toBoolean(@(1,isOfAge))"
      }
     ....
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3- Regarding converting the date value "joiningDate" to number , this is tricky and I dont think you can do it via Jolt, you either have to extract it using EvaluateJsonPath as an attribute then do update attribute using expression language to do the proper formatting and conversion. Since JoltTransformation spec allows expression language , you can reference this attribute in the modify spec. here is an example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/76678896/jolt-how-to-convert-datetimestamp-to-epoch-on-dynamic-json-keys" target="_blank"&gt;https://stackoverflow.com/questions/76678896/jolt-how-to-convert-datetimestamp-to-epoch-on-dynamic-json-keys&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Another option is to use UpdateRecord to do the proper formatting, conversion for all attributes that require such thing and then just use basic shift spec to re arrange values accordingly. With UpdateRecord you need to use Avro Schema to define the proper types in the JsonRecordSetWriter.&lt;/P&gt;&lt;P&gt;UpdateRecord:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_0-1702658706215.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39197i7B898D53449B4E69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_0-1702658706215.png" alt="SAMSAL_0-1702658706215.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JsonRecordSetWriter:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_1-1702658737506.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39198iF0C85ADD21556DE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_1-1702658737506.png" alt="SAMSAL_1-1702658737506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AvroSchema in the Schema Text Property:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "type": "record",
  "name": "nifi-record",
  "fields":
  [
    { "name": "id", "type": "string"},
    { "name": "system", "type": "string"},
    { "name": "sourceSystem", "type": "string"},
    { "name": "name", "type": "string"},
	{ "name": "lastName", "type": "string"},
	{ "name": "mail", "type": "string"},
	{ "name": "country", "type": "string"},
	{ "name": "city", "type": "string"},
	{ "name": "street", "type": "string"},
	{ "name": "building", "type": "string"},
	{ "name": "local", "type": "string"},
	{ "name": "paycheck", "type": "double"},
	{ "name": "joiningDate", "type": { "type":"int", "logicalType":"date" }},
    { "name": "isOfAge", "type": ["boolean","null"]}
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you find this helpful please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2023 16:49:03 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2023-12-15T16:49:03Z</dc:date>
    <item>
      <title>Problem with JoltTransformation in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380841#M244185</link>
      <description>&lt;P&gt;Hi guys! i have some problems with JoltTransformation in NIFI. I have plain json like that:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"id": "c47f79f5-77b1-45d1-91df-968c2fa3def8",&lt;BR /&gt;"system" : "OP",&lt;BR /&gt;"sourceSystem" : "DKG",&lt;BR /&gt;"name" : "Agnes",&lt;BR /&gt;"lastName" : "Smith",&lt;BR /&gt;"mail" : "a.smith@gmail.com",&lt;BR /&gt;"country" : "Australia",&lt;BR /&gt;"city" : "Sydney",&lt;BR /&gt;"street" : "Colorado",&lt;BR /&gt;"building" : "23",&lt;BR /&gt;"local" : "1',&lt;BR /&gt;"paycheck" : "3456,98',&lt;BR /&gt;"joiningDate" : "12-09-2023",&lt;BR /&gt;"isOfAge": "true",&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;And i need to have output like this:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"paycheck":3456.98,&lt;BR /&gt;"joiningDate":1702048486451,&lt;BR /&gt;"person":{&lt;BR /&gt;"name":"Agnes",&lt;BR /&gt;"lastName":"Smith",&lt;BR /&gt;"mail":"a.smith@gmail.com",&lt;BR /&gt;"isOfAge":true,&lt;BR /&gt;"adress":{&lt;BR /&gt;"country":"Australia",&lt;BR /&gt;"city":"Sydney",&lt;BR /&gt;"street":"Colorado",&lt;BR /&gt;"building":"23",&lt;BR /&gt;"local":"1"&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;"system_data":{&lt;BR /&gt;"id":"c47f79f5-77b1-45d1-91df-968c2fa3def8",&lt;BR /&gt;"system":"OP",&lt;BR /&gt;"sourceSystem":"DKG"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;In addition to nesting, I need to convert date to long, paycheck to double and isOfAge to boolean.I tried use JoltTransformation and Jolt Specification like this:&lt;/P&gt;&lt;P&gt;[&lt;BR /&gt;{&lt;BR /&gt;"operation":"shift",&lt;BR /&gt;"spec":{&lt;BR /&gt;"paycheck":"paycheck",&lt;BR /&gt;"joiningDate":"joiningDate",&lt;BR /&gt;"name" : "person.name",&lt;BR /&gt;"lastName" : "person.lastName",&lt;BR /&gt;"mail" : "person.mail",&lt;BR /&gt;"isOfAge" : "person.isOfAge",&lt;BR /&gt;"country" : "person.adress.country",&lt;BR /&gt;"city" : "person.adress.city",&lt;BR /&gt;"street" : "person.adress.street",&lt;BR /&gt;"building" : "person.adress.building",&lt;BR /&gt;"local" : "person.adress.local",&lt;BR /&gt;"id" : "system_data.id",&lt;BR /&gt;"system" : "system_data.system",&lt;BR /&gt;"sourceSystem" : "system_data.sourceSystem"&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"operation": "modify-overwrite-beta",&lt;BR /&gt;"spec": {&lt;BR /&gt;"paycheck": "=toDouble",&lt;BR /&gt;"joiningDate": "=toNumber",&lt;BR /&gt;"isOfAge": "=toBoolean"&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nesting works but type conversion not. What am I doing wrong because i admit that jolt is little bit complicated for me&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 13:22:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380841#M244185</guid>
      <dc:creator>MWM</dc:creator>
      <dc:date>2023-12-15T13:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JoltTransformation in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380847#M244186</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105912"&gt;@MWM&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;There are couple of issues I noticed regarding the input json and the spec:&lt;/P&gt;&lt;P&gt;1- Regarding the "paycheck" value "3456,98" , I noticed there is coma (,) is that correct? if that is the case , Im not sure the conversion will work in this case.&amp;nbsp; You have to probably replace the coma with dot (.) and then convert toDouble. It takes few steps to do this in jolt since there is no string replace function using split, join as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;,
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      ....
      "paycheckArray": "=split('[,]',@(1,paycheck))",
      "paycheckJoin": "=join('.',@(1,paycheckArray))",
      "paycheck": "=toDouble(@(1,paycheckJoin))",
      ....
    }
}
,
  {
    "operation": "remove",
    "spec": {
      "paycheckArray": "",
      "paycheckJoin": ""
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- Regarding the boolean value "isOfAge" , since you have moved it under person object, the spec would as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "operation": "modify-overwrite-beta",
    "spec": {
      ...
      "person": {
        "isOfAge": "=toBoolean(@(1,isOfAge))"
      }
     ....
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3- Regarding converting the date value "joiningDate" to number , this is tricky and I dont think you can do it via Jolt, you either have to extract it using EvaluateJsonPath as an attribute then do update attribute using expression language to do the proper formatting and conversion. Since JoltTransformation spec allows expression language , you can reference this attribute in the modify spec. here is an example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/76678896/jolt-how-to-convert-datetimestamp-to-epoch-on-dynamic-json-keys" target="_blank"&gt;https://stackoverflow.com/questions/76678896/jolt-how-to-convert-datetimestamp-to-epoch-on-dynamic-json-keys&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Another option is to use UpdateRecord to do the proper formatting, conversion for all attributes that require such thing and then just use basic shift spec to re arrange values accordingly. With UpdateRecord you need to use Avro Schema to define the proper types in the JsonRecordSetWriter.&lt;/P&gt;&lt;P&gt;UpdateRecord:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_0-1702658706215.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39197i7B898D53449B4E69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_0-1702658706215.png" alt="SAMSAL_0-1702658706215.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JsonRecordSetWriter:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAMSAL_1-1702658737506.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39198iF0C85ADD21556DE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAMSAL_1-1702658737506.png" alt="SAMSAL_1-1702658737506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AvroSchema in the Schema Text Property:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "type": "record",
  "name": "nifi-record",
  "fields":
  [
    { "name": "id", "type": "string"},
    { "name": "system", "type": "string"},
    { "name": "sourceSystem", "type": "string"},
    { "name": "name", "type": "string"},
	{ "name": "lastName", "type": "string"},
	{ "name": "mail", "type": "string"},
	{ "name": "country", "type": "string"},
	{ "name": "city", "type": "string"},
	{ "name": "street", "type": "string"},
	{ "name": "building", "type": "string"},
	{ "name": "local", "type": "string"},
	{ "name": "paycheck", "type": "double"},
	{ "name": "joiningDate", "type": { "type":"int", "logicalType":"date" }},
    { "name": "isOfAge", "type": ["boolean","null"]}
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you find this helpful please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 16:49:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380847#M244186</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-12-15T16:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with JoltTransformation in NIFI</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380960#M244194</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;Thank you for help, everything works unfortunately except the date, but as you said, it is more complicated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 13:01:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Problem-with-JoltTransformation-in-NIFI/m-p/380960#M244194</guid>
      <dc:creator>MWM</dc:creator>
      <dc:date>2023-12-18T13:01:50Z</dc:date>
    </item>
  </channel>
</rss>

