<?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: Convert Json array into csv using Nifi produces MapRecord in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347755#M235250</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use FlattenJson processor to flatten your json before converting to CSV. The output Json after flattening will be something like this:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"id": "aaaa",&lt;BR /&gt;"billingaddress.city": null,&lt;BR /&gt;"billingaddress.country": "CHINA",&lt;BR /&gt;"billingaddress.geocodeAccuracy": null,&lt;BR /&gt;"billingaddress.latitude": null,&lt;BR /&gt;"billingaddress.longitude": null,&lt;BR /&gt;"billingaddress.postalCode": null,&lt;BR /&gt;"billingaddress.state": null,&lt;BR /&gt;"billingaddress.street": null&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another Option is to use JoltTransformJSON to flatten your json if you don't like the "billingaddress." prefix. You can use the following Jolt Spec:&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;[&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; "operation": "shift",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; "spec": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "id",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "billingaddress": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "*": "&amp;amp;"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Which will produce the following json:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;{&lt;BR /&gt;"id" : "aaaa",&lt;BR /&gt;"city" : null,&lt;BR /&gt;"country" : "CHINA",&lt;BR /&gt;"geocodeAccuracy" : null,&lt;BR /&gt;"latitude" : null,&lt;BR /&gt;"longitude" : null,&lt;BR /&gt;"postalCode" : null,&lt;BR /&gt;"state" : null,&lt;BR /&gt;"street" : null&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If you think this solves the issue please accept solution. Thanks&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Jul 2022 12:33:33 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2022-07-15T12:33:33Z</dc:date>
    <item>
      <title>Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347745#M235249</link>
      <description>&lt;P&gt;JsonTreeReader to CSV Writer produces MapRecord String for the inner Json.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;"id" : "aaaa",&lt;/P&gt;&lt;P&gt;"billingaddress" : {&lt;BR /&gt;"city" : null,&lt;BR /&gt;"country" : "CHINA",&lt;BR /&gt;"geocodeAccuracy" : null,&lt;BR /&gt;"latitude" : null,&lt;BR /&gt;"longitude" : null,&lt;BR /&gt;"postalCode" : null,&lt;BR /&gt;"state" : null,&lt;BR /&gt;"street" : null&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Produces CSV out with MapRecord String attached.&amp;nbsp;&lt;/P&gt;&lt;P&gt;aaaa|MapRecord[{country=CHINA, city=null, street=null, latitude=null, postalCode=null, geocodeAccuracy=null, state=null, longitude=null}]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Expected Output:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;aaaa|{country=CHINA, city=null, street=null, latitude=null, postalCode=null, geocodeAccuracy=null, state=null, longitude=null}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep the inner JSON as-is in the CSV output. Any workarounds to this issue?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:41:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347745#M235249</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2022-07-15T12:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347755#M235250</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use FlattenJson processor to flatten your json before converting to CSV. The output Json after flattening will be something like this:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"id": "aaaa",&lt;BR /&gt;"billingaddress.city": null,&lt;BR /&gt;"billingaddress.country": "CHINA",&lt;BR /&gt;"billingaddress.geocodeAccuracy": null,&lt;BR /&gt;"billingaddress.latitude": null,&lt;BR /&gt;"billingaddress.longitude": null,&lt;BR /&gt;"billingaddress.postalCode": null,&lt;BR /&gt;"billingaddress.state": null,&lt;BR /&gt;"billingaddress.street": null&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another Option is to use JoltTransformJSON to flatten your json if you don't like the "billingaddress." prefix. You can use the following Jolt Spec:&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;[&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; "operation": "shift",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp; "spec": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "id",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "billingaddress": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "*": "&amp;amp;"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Which will produce the following json:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;{&lt;BR /&gt;"id" : "aaaa",&lt;BR /&gt;"city" : null,&lt;BR /&gt;"country" : "CHINA",&lt;BR /&gt;"geocodeAccuracy" : null,&lt;BR /&gt;"latitude" : null,&lt;BR /&gt;"longitude" : null,&lt;BR /&gt;"postalCode" : null,&lt;BR /&gt;"state" : null,&lt;BR /&gt;"street" : null&lt;BR /&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If you think this solves the issue please accept solution. Thanks&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:33:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347755#M235250</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-15T12:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347761#M235252</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;&amp;nbsp; I need to retain the JSON format as-is in the output. I have updated the updated the expected output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Expected Output:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;aaaa|{country=CHINA, city=null, street=null, latitude=null, postalCode=null, geocodeAccuracy=null, state=null, longitude=null}&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 12:43:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347761#M235252</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2022-07-15T12:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347765#M235254</link>
      <description>&lt;P&gt;In this case I would suggest ReplaceText processor with the Search Value set to:&lt;/P&gt;&lt;P&gt;(MapRecord|\[|\])&lt;/P&gt;&lt;P&gt;And Replacement Value is set to Empty String.This will produce the result:&lt;/P&gt;&lt;P&gt;aaaa|"{country=CHINA, city=null, street=null, latitude=null, postalCode=null, geocodeAccuracy=null, state=null, longitude=null}"&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 13:06:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347765#M235254</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-15T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347988#M235290</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/85385"&gt;@Althotta&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. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 17:23:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/347988#M235290</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2022-07-18T17:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/348675#M235425</link>
      <description>&lt;P&gt;Not yet resolved.&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp; solution is a potential workaround. Iam looking for a right solution why &lt;SPAN&gt;Convert&amp;nbsp;produces this as i have few places to change.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 09:26:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/348675#M235425</guid>
      <dc:creator>Althotta</dc:creator>
      <dc:date>2022-07-25T09:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Json array into csv using Nifi produces MapRecord</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/362453#M238781</link>
      <description>&lt;P&gt;I had a similar issue, it happens because of nifi not being able to resolve the schema. You need to first create a schema and set the type of billing address as string and add it to avroschemaregistry and lastly configure your jsontreereader to use that schema&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jan 2023 16:49:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Convert-Json-array-into-csv-using-Nifi-produces-MapRecord/m-p/362453#M238781</guid>
      <dc:creator>arshad10244</dc:creator>
      <dc:date>2023-01-29T16:49:04Z</dc:date>
    </item>
  </channel>
</rss>

