<?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 NiFi - converting JSON array into Avro Map in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345221#M234433</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On our use case, we're receiving data in JSON format and it must be converted into Avro using a schema that has X and Y includes mandatory fields and everything else (Z and W) should go into a Custom map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is our Avro schema:&lt;/P&gt;&lt;P&gt;"fields": [&lt;BR /&gt;{"name": "X", "type": "long"},&lt;BR /&gt;{"name": "Y", "type": "string"},&lt;BR /&gt;{"name": "Custom", "type": { "type": "map", "values": "string" } }&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And an example of data coming in:&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"X":123,&lt;/P&gt;&lt;P&gt;"Y":"ABC",&lt;/P&gt;&lt;P&gt;"Z":"zzz",&lt;/P&gt;&lt;P&gt;"W":"www"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have implemented a JoltTransform to do the needed transformation to get Z and W into a Custom array.&lt;/P&gt;&lt;P&gt;Now the issue is on doing the conversion from JSON into Avro since we get an error stating it cannot convert an java.lang.Object into a Map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can we properly process this JSON and put that array into a Map so it can be properly stored using that Avro schema?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jun 2022 14:51:41 GMT</pubDate>
    <dc:creator>migu</dc:creator>
    <dc:date>2022-06-08T14:51:41Z</dc:date>
    <item>
      <title>NiFi - converting JSON array into Avro Map</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345221#M234433</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On our use case, we're receiving data in JSON format and it must be converted into Avro using a schema that has X and Y includes mandatory fields and everything else (Z and W) should go into a Custom map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is our Avro schema:&lt;/P&gt;&lt;P&gt;"fields": [&lt;BR /&gt;{"name": "X", "type": "long"},&lt;BR /&gt;{"name": "Y", "type": "string"},&lt;BR /&gt;{"name": "Custom", "type": { "type": "map", "values": "string" } }&lt;BR /&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And an example of data coming in:&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"X":123,&lt;/P&gt;&lt;P&gt;"Y":"ABC",&lt;/P&gt;&lt;P&gt;"Z":"zzz",&lt;/P&gt;&lt;P&gt;"W":"www"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have implemented a JoltTransform to do the needed transformation to get Z and W into a Custom array.&lt;/P&gt;&lt;P&gt;Now the issue is on doing the conversion from JSON into Avro since we get an error stating it cannot convert an java.lang.Object into a Map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can we properly process this JSON and put that array into a Map so it can be properly stored using that Avro schema?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 14:51:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345221#M234433</guid>
      <dc:creator>migu</dc:creator>
      <dc:date>2022-06-08T14:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - converting JSON array into Avro Map</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345249#M234451</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98460"&gt;@migu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's your NiFi version and what's your JOLT transformation?&lt;/P&gt;&lt;P&gt;This should work, provided that your JOLTed JSON is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see the attached flow, which works fine for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;André&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 03:08:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345249#M234451</guid>
      <dc:creator>araujo</dc:creator>
      <dc:date>2022-06-09T03:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - converting JSON array into Avro Map</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345489#M234546</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/98460"&gt;@migu&lt;/a&gt;&amp;nbsp;Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. If you are still experiencing the issue, can you provide the information @araujo has requested? Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 15:52:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-converting-JSON-array-into-Avro-Map/m-p/345489#M234546</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2022-06-13T15:52:57Z</dc:date>
    </item>
  </channel>
</rss>

