<?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 add custom attributes to AttributesToJSON? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308391#M223530</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Matt,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Great,&amp;nbsp; with your suggestion, I got what I was expecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;--Murali&lt;/P&gt;</description>
    <pubDate>Wed, 23 Dec 2020 17:33:37 GMT</pubDate>
    <dc:creator>murali2425</dc:creator>
    <dc:date>2020-12-23T17:33:37Z</dc:date>
    <item>
      <title>How to add custom attributes to AttributesToJSON?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308326#M223521</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a scenario where list of files are coming from previous processor, where for each file, I have to create json file with attributes of the flowfile. In AttributesToJSON processor configuration there is option to extract pipeline attributes and can create json files/object, if we set Include Core Attributes to true, it will read some of the file properties and forms the json file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AttributesToJSON.PNG" style="width: 801px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/29872i10BDAD04C93B553F/image-size/large?v=v2&amp;amp;px=999" role="button" title="AttributesToJSON.PNG" alt="AttributesToJSON.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;the out for the above case in my scenario is …
{"fragment.size":"125"
file.group:"root",
file.lastModifiedTime:"2020-12-22T15:09:13+0000",
fragment.identifier:"ee5770ea-8406-400a-a2fd-2362bd706fe0",
fragment.index:"1",
file.creationTime:"2020-12-22T15:09:13+0000",
file.lastAccessTime:"2020-12-22T17:34:22+0000",
segment.original.filename:"Sample-Spreadsheet-10000-rows.csv",
file.owner:"root",
fragment.count:"2",
file.permissions:"rw-r--r--",
text.line.count:"1"}
}



 But the files has other properties, like absolute.path, filename, uuid  are missing in the above json file.
    My requirement is, get the absolute.path, filename and uuid and concatenate absolute.path+/+filename, assign this to custom attribute say filepath:absolute.path+/+filename and also add uuid to json object.  &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so my json file should like&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{ uuid:"file uuid value", filepath:"absolute.path+/+filename" } &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;any inputs to get above&amp;nbsp; form of json file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 13:30:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308326#M223521</guid>
      <dc:creator>murali2425</dc:creator>
      <dc:date>2020-12-23T13:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom attributes to AttributesToJSON?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308340#M223526</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/72826"&gt;@murali2425&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was not able to reproduce the missing attributes in the content of a produced FlowFile from the AttributesToJson processor.&amp;nbsp; What version of NiFi are you using?&amp;nbsp; Did you inspect the attributes on the FlowFile in the immediate connection feeding the AttributesToJson before starting that processor?&lt;BR /&gt;&lt;BR /&gt;Your desired output from the AttributesToJson seems to be very specific and not include all attributes including the core attributes anyway.&lt;BR /&gt;&lt;BR /&gt;My suggestion would be to use an UpdateAttribute processor just before your AttributesToJson processor to build the specific attributes you want to have in your produced Json output content.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;You would then add two custom dynamic properties where you would use NiFi Expression Language to populate the values from other attributes/metadata on the source FlowFile:&lt;/P&gt;
&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-23 at 10.33.38 AM.png" style="width: 776px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/29885i777CAE508C8E1659/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-12-23 at 10.33.38 AM.png" alt="Screen Shot 2020-12-23 at 10.33.38 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could then configure your AttributesToJson processor to build the JSON content using only those two new attributes you just constructed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-23 at 10.14.24 AM.png" style="width: 811px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/29880i89A51E02D5BFB3B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-12-23 at 10.14.24 AM.png" alt="Screen Shot 2020-12-23 at 10.14.24 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Keep in mind that the AttributesToJson processor will add attributes to the Json in Lexicographical order. So if you want the uuid before the filepath, you will need to adjust the property names used in the UpdateAttribute processor.&lt;BR /&gt;&lt;BR /&gt;For example&lt;BR /&gt;"auuid" instead of "myuuid" so that it comes before "filepath" in order.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Matt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 15:38:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308340#M223526</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2020-12-23T15:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom attributes to AttributesToJSON?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308391#M223530</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Matt,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Great,&amp;nbsp; with your suggestion, I got what I was expecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;--Murali&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 17:33:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-add-custom-attributes-to-AttributesToJSON/m-p/308391#M223530</guid>
      <dc:creator>murali2425</dc:creator>
      <dc:date>2020-12-23T17:33:37Z</dc:date>
    </item>
  </channel>
</rss>

