<?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: How to do JOLT replace on all JSON keys in Nifi in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178417#M75756</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Maybe, one more thing:&lt;/P&gt;&lt;P&gt;-I would preferably don't want to do any hardcoding, since the JSON has many keys I am specifically looking for a dynamic way &lt;/P&gt;&lt;P&gt;I came across JOLT functions like =toLower / =join and was kind of hoping for =replace but that one seems missing. &lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2018 20:24:57 GMT</pubDate>
    <dc:creator>jknulst</dc:creator>
    <dc:date>2018-03-13T20:24:57Z</dc:date>
    <item>
      <title>How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178416#M75755</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a requirement for transforming JSON on Nifi which seems simple but I haven't been able to solve:&lt;/P&gt;&lt;P&gt;Input json:&lt;/P&gt;&lt;PRE&gt;{
	"agent-submit-time" : -1,
	"agent-end-time" : 123445,
	"agent-name" : "Marie Bayer-Smith"
}&lt;/PRE&gt;&lt;P&gt;Desired:&lt;/P&gt;&lt;PRE&gt;{
	"agent_submit_time" : -1,
	"agent_end_time" : 123445,
	"agent_name" : "Marie Bayer-Smith"
}&lt;/PRE&gt;&lt;P&gt;-I don't want to use the ReplaceText processor since replacing "-" for "_" might impact values too&lt;/P&gt;&lt;P&gt;-I need this to be able to infer AVRO schema on incoming JSON records (AVRO does not like the dashes at all)&lt;/P&gt;&lt;P&gt;-since I already use a Jolt processor for another transformation in the JSON it makes sense to include it in the same processor to prevent unnecessary Nifi overhead. &lt;/P&gt;&lt;P&gt;I think I would need the JoltTransformJSON processor as it is very powerful (but the syntax evades me) for this but open for other options too.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:17:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178416#M75755</guid>
      <dc:creator>jknulst</dc:creator>
      <dc:date>2018-03-13T19:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178417#M75756</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Maybe, one more thing:&lt;/P&gt;&lt;P&gt;-I would preferably don't want to do any hardcoding, since the JSON has many keys I am specifically looking for a dynamic way &lt;/P&gt;&lt;P&gt;I came across JOLT functions like =toLower / =join and was kind of hoping for =replace but that one seems missing. &lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 20:24:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178417#M75756</guid>
      <dc:creator>jknulst</dc:creator>
      <dc:date>2018-03-13T20:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178418#M75757</link>
      <description>&lt;P&gt;You can use the following JOLT spec in the JoltTransformJSON processor:&lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "*-*-*": "&amp;amp;(0,1)_&amp;amp;(0,2)_&amp;amp;(0,3)",
      "*-*": "&amp;amp;(0,1)_&amp;amp;(0,2)",
      "*": "&amp;amp;"
    }
  }
]&lt;/PRE&gt;&lt;P&gt;Note that you have to add an entry for each "level" of name matching, so if you could have elements with 4 dashes, you'd need an extra line at the top, following the same pattern.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 00:12:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178418#M75757</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-03-14T00:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178419#M75758</link>
      <description>&lt;P&gt;Hi Jasper&lt;/P&gt;&lt;P&gt;You can use the JoltTransformJson processor to get it done. Follows how should your processor config look like.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64596-jolt-specification.png" style="width: 728px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19482iCCD3576283B59AB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64596-jolt-specification.png" alt="64596-jolt-specification.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Follows the complete Jolt specification.&lt;/P&gt;&lt;PRE&gt;[ 
 { "operation": "shift", 
 "spec": { 
  "agent-submit-time": "agent_submit_time", 
  "agent-end-time": "agent_end_time", 
  "agent-name": "agent_name", 
  "*": { 
   "@": "&amp;amp;" 
  } 
 } 
 } 
] &lt;/PRE&gt;&lt;P&gt;Follows a snippet of the output I got using your input.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64597-screen-shot-2018-03-13-at-15315-pm.png" style="width: 434px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19483i066FF72AE7D9CF78/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64597-screen-shot-2018-03-13-at-15315-pm.png" alt="64597-screen-shot-2018-03-13-at-15315-pm.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 09:32:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178419#M75758</guid>
      <dc:creator>RahulSoni</dc:creator>
      <dc:date>2019-08-18T09:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178420#M75759</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/66220/rsoni.html" nodeid="66220"&gt;@Rahul Soni&lt;/A&gt; Thanks for your answer but I really don't want to hardcode all of my 50+ JSON fields&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 01:13:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178420#M75759</guid>
      <dc:creator>jknulst</dc:creator>
      <dc:date>2018-03-14T01:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178421#M75760</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt; I don't get the syntax, but it works like a charm! Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 02:32:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178421#M75760</guid>
      <dc:creator>jknulst</dc:creator>
      <dc:date>2018-03-14T02:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178422#M75761</link>
      <description>&lt;P&gt;JOLT can be fairly complicated. In this case the * on the left is a non-greedy match, the &amp;amp;(x,y) on the right is to grab the individual pieces.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 02:55:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178422#M75761</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-03-14T02:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178423#M75762</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;&lt;/P&gt;&lt;P&gt;How to do this for more complex example like below: Please help.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;{&lt;BR /&gt;"firstname" : "John"&lt;BR /&gt;"address" : { "Convert-this": [ "not-this","also-not-this "],&lt;BR /&gt;  "Again-convert-this":[ "but-not-this","also-not-this","no-for-this-too" ]&lt;BR /&gt;  }&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 01:24:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178423#M75762</guid>
      <dc:creator>amitpatel50</dc:creator>
      <dc:date>2018-08-15T01:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178424#M75763</link>
      <description>&lt;P&gt;This one is only more complex because you want to convert the field names at the second level not the first, so you want to match "address" first, then use the above spec for each field in there, and then also transfer any fields at the top level over as-is (namely "firstname", the spec (which is specific for this example) is: &lt;/P&gt;&lt;PRE&gt;[
  {
    "operation": "shift",
    "spec": {
      "address": {
        "*-*-*": "&amp;amp;(0,1)_&amp;amp;(0,2)_&amp;amp;(0,3)",
        "*-*": "&amp;amp;(0,1)_&amp;amp;(0,2)",
        "*": "&amp;amp;"
      },
      "*": "&amp;amp;"
    }
  }
]&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Aug 2018 01:42:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178424#M75763</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-08-15T01:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178425#M75764</link>
      <description>&lt;P style="margin-left: 20px;"&gt;Thanks @Matt Burgess&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;I will try it and let you know if it gives problems.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 01:33:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178425#M75764</guid>
      <dc:creator>amitpatel50</dc:creator>
      <dc:date>2018-08-16T01:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to do JOLT replace on all JSON keys in Nifi</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178426#M75765</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.hortonworks.com/users/641/mburgess.html"&gt;@Matt Burgess&lt;/A&gt; It works fine if there is just one object in the input tree if there are more it makes them as an array rather than separate records. Like&lt;/P&gt;&lt;PRE&gt;{
&amp;nbsp; "agent_submit_time" : [ -1, -1 ],
&amp;nbsp; "agent_end_time" : [ 123445, 123445 ],
&amp;nbsp; "agent_name" : [ "Marie Bayer-Smith", "Marie Bayer-Smith" ]
}&lt;/PRE&gt;&lt;HR /&gt;&lt;P&gt; I would like to to be something like&lt;/P&gt;&lt;HR /&gt;&lt;PRE&gt;&lt;CODE&gt;[
{
  "agent_submit_time" : -1,
  "agent_end_time" : 123445,
  "agent_name" : "Marie Bayer-Smith"
},
{
  "agent_submit_time" : -1,
  "agent_end_time" : 123445,
  "agent_name" : "Marie Bayer-Smith"
}
]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How to do that. I tried but I couldnt replaceing  "*": "&amp;amp;" with "@": "[&amp;amp;]" makes it separate but the transformation of - to _ doesnt takes place. &lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 21:01:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-do-JOLT-replace-on-all-JSON-keys-in-Nifi/m-p/178426#M75765</guid>
      <dc:creator>usama_kaleem88</dc:creator>
      <dc:date>2019-03-28T21:01:56Z</dc:date>
    </item>
  </channel>
</rss>

