<?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: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298556#M219237</link>
    <description>&lt;P&gt;That is what I would have expected based on the explanation. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What was your expected outcome? &amp;nbsp; &amp;nbsp;That would help me make a further suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jun 2020 13:40:45 GMT</pubDate>
    <dc:creator>stevenmatison</dc:creator>
    <dc:date>2020-06-24T13:40:45Z</dc:date>
    <item>
      <title>NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/297939#M218900</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I'm using NiFi 1.11.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a set of Json-files which contain a base64-coded field (Jsonpath to this field is $.data.content).&amp;nbsp; Decoding the field works as expected and I'm able to write the content from this field to a file in a bucket in S3.&amp;nbsp; But what I would like to do is to be able to replace the coded value for this field with the decoded value in stead of writing the decoded value to file. And after replacing the value write the updated Json-file to a new S3 bucket.&lt;/P&gt;&lt;P&gt;I'm thinking taking the output from RouteOnAttribute and ConvertRecord in the figure below and perhaps use UpdateRecord or ReplaceText. But I'm not sure how to do this.&lt;/P&gt;&lt;P&gt;What is the best way to "re-connect" the data flow here from these to objects in the process?&lt;/P&gt;&lt;P&gt;Any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;bjornmy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&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="nifi.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/27972iC7BEF5D2C45E7C7B/image-size/large?v=v2&amp;amp;px=999" role="button" title="nifi.png" alt="nifi.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 09:08:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/297939#M218900</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-12T09:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298462#M219185</link>
      <description>&lt;P&gt;Any input would be appreciated guys.&lt;/P&gt;&lt;P&gt;The output from the ConvertRecord is a JSON-document, and I would like to replace the value of $.data.content from the originale file with this JSON-document.&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 10:28:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298462#M219185</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-23T10:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298466#M219188</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78963"&gt;@bjornmy&lt;/a&gt;&amp;nbsp;The solution you are looking for is to use updateAttribute to operate on the attribute you want to modify with the &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#base64encode" target="_blank" rel="noopener"&gt;NiFi Expression Language&lt;/A&gt; for base64encode/base64decode. &amp;nbsp; &amp;nbsp;This will operate on the flowfile attribute in contrast to the Base64EncodeContent processor which acts on the flowfile content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming encoded content =&amp;gt; $.data.content in EvaluateJson, the updateAttribute for content will look like:&lt;/P&gt;&lt;PRE&gt;${content:base64decode()}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may need to evaluate all the attributes you need to use. &amp;nbsp;Once you have the attribute(s) formatted the way you want, you then use AttributesToJson (configuration set to flowfile-content) to rebuild the json object you want to send content of the flowfile downstream to the final S3 Bucket. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry I can't be more specific on the last parts, as I did not create a test sample, and &amp;nbsp;I cannot see exactly what you are doing with ReplaceText-&amp;gt;Base64EncodeContent-&amp;gt;ConvertRecord.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Steven&amp;nbsp;@ DFHZ&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 12:02:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298466#M219188</guid>
      <dc:creator>stevenmatison</dc:creator>
      <dc:date>2020-06-23T12:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298536#M219225</link>
      <description>&lt;P&gt;Thank you for your input &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/60150"&gt;@stevenmatison&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below you will find more info, and I have also enclosed a test json-file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main source here is JSON-documents, and as mentioned above the value in $.data.content in these files is a base64encoded &lt;U&gt;XML-document&lt;/U&gt;.&amp;nbsp; That is the reason for the ConvertRecord (see below).&amp;nbsp; If it not had been for this I suspect your suggestion would work fine. The flow that I have made so far is extracting the value from $.data.content, decodes it, converts the XML to JSON and finally stores the JSON-content from this base64-field to S3.&amp;nbsp; And it's the encoded data in $.data.content in the main document I would like to have replaced with the decoded/coneverted JSON-document, and then store the updated version of the main file in S3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The EvaluateJsonPath looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="EvaluateJsonPath.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28061iC5FD865FE86CF952/image-size/large?v=v2&amp;amp;px=999" role="button" title="EvaluateJsonPath.png" alt="EvaluateJsonPath.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ReplaceText looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ReplaceText.png" style="width: 798px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28062i5DF00491659793F1/image-size/large?v=v2&amp;amp;px=999" role="button" title="ReplaceText.png" alt="ReplaceText.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The Base64EncodeContent looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Base64Decode.png" style="width: 795px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28063i98D41472FC37AB2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Base64Decode.png" alt="Base64Decode.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and finally the ConvertRecord looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ConvertRecord.png" style="width: 803px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28064i1B83A1C5BD571213/image-size/large?v=v2&amp;amp;px=999" role="button" title="ConvertRecord.png" alt="ConvertRecord.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is what a test json-file would look like.&amp;nbsp; Here you can see the $.data.content encoded value I need to replace with the corresponding decoded/converted json-value, before writing the updated content to S3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;{
  "header": {
    "dokumentidentifikator": null,
    "dokumentidentifikatorV2": "dcff985b-c652-4085-b8f1-45a2f4b6d150",
    "revisjonsnummer": 1,
    "dokumentnavn": "Engangsavgiftfastsettelse:1122334455:44BIL1:2017-10-20",
    "dokumenttype": "SKATTEMELDING_ENGANGSAVGIFT",
    "dokumenttilstand": "OPPRETTET",
    "gyldig": true,
    "gjelderInntektsaar": 2017,
    "gjelderPeriode": "2017_10",
    "gjelderPart": {
      "partsnummer": 5544332211,
      "identifiseringstype": "MASKINELL",
      "identifikator": null
    },
    "opphavspart": {
      "partsnummer": 5544332211,
      "identifikator": null
    },
    "kildereferanse": {
      "kildesystem": "ENGANGSAVGIFTFASTSETTELSE",
      "gruppe": "",
      "referanse": "aef147fb-8ce8-43ef-833b-7aa3bac1ece0",
      "tidspunkt": "2018-01-16T13:28:02.49+01:00"
    }
  },
  "data": {
    "metadata": {
      "format": "motorvogn:motorvognavgift:v1",
      "bytes": 4420,
      "mimeType": "application/xml",
      "sha1": "c0AowOsTdNdo6VufeSsZqTphc0Y="
    },
    "content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8bW90b3J2b2duYXZnaWZ0IHhtbG5zPSJza2U6ZmFzdHNldHRpbmc6bW90b3J2b2duOm1vdG9ydm9nbmF2Z2lmdDp2MSI+CiAgICA8YXZnaWZ0c2xpbmplPgogICAgICAgIDxhdmdpZnRzYmVsb2VwPjU0Mjg5Ni4wMDwvYXZnaWZ0c2JlbG9lcD4KICAgICAgICA8YXZnaWZ0c29wcGx5c25pbmc+CiAgICAgICAgICAgIDxzYWVyYXZnaWZ0VHlwZWtvZGU+QkI8L3NhZXJhdmdpZnRUeXBla29kZT4KICAgICAgICAgICAgPHNhZXJhdmdpZnRHcnVwcGVrb2RlPlg8L3NhZXJhdmdpZnRHcnVwcGVrb2RlPgogICAgICAgIDwvYXZnaWZ0c29wcGx5c25pbmc+CiAgICAgICAgPGF2Z2lmdHNkYXRvPjIwMTctMTAt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nZGU+CiAgICAgICAgICAgIDxtb3RvcmVmZmVrdD45NjwvbW90b3JlZmZla3Q+CiAgICAgICAgICAgIDxzbGFndm9sdW0+MTQzPC9zbGFndm9sdW0+CiAgICAgICAgICAgIDxkcml2c3RvZmY+QkVOU0lOPC9kcml2c3RvZmY+CiAgICAgICAgICAgIDxlZ2VudmVrdD4xNTE5PC9lZ2VudmVrdD4KICAgICAgICAgICAgPGVpZXI+CiAgICAgICAgICAgICAgICA8Zm9lZHNlbHNFbGxlckRudW1tZXI+MTEyMjMzNDQ1NTwvZm9lZHNlbHNFbGxlckRudW1tZXI+CiAgICAgICAgICAgICAgICA8cGFydHNudW1tZXI+NTU0NDMzMjIxMTwvcGFydHNudW1tZXI+CiAgICAgICAgICAgICAgICA8bmF2bj5LTEFSQSBLVTwvbmF2bj4KICAgICAgICAgICAgPC9laWVyPgogICAgICAgICAgICA8dGlsbGF0dFRvdGFsdmVrdD4yMTY0PC90aWxsYXR0VG90YWx2ZWt0PgogICAgICAgICAgICA8aHlicmlkPm5laTwvaHlicmlkPgogICAgICAgICAgICA8Y28ydXRzbGlwcD4yNjg8L2NvMnV0c2xpcHA+CiAgICAgICAgICAgIDxub3h1dHNsaXBwPjU5LjQ8L25veHV0c2xpcHA+CiAgICAgICAgICAgIDxram9lcmV0b2V5aWRlbnRpZmlrYXRvcj4KICAgICAgICAgICAgICAgIDxram9lcmV0b2V5VW5pa0lkZW50aWZpa2F0b3I+QUJDREVGR0hJSjwva2pvZXJldG9leVVuaWtJZGVudGlmaWthdG9yPgogICAgICAgICAgICAgICAgPGtqZW5uZW1lcmtlPjQ0QklMMTwva2plbm5lbWVya2U+CiAgICAgICAgICAgICAgICA8dW5kZXJzdGVsbHNudW1tZXI+VU5ERVJTVEVMTDQ0PC91bmRlcnN0ZWxsc251bW1lcj4KICAgICAgICAgICAgPC9ram9lcmV0b2V5aWRlbnRpZmlrYXRvcj4KICAgICAgICA8L2tqb2VyZXRvZXk+CiAgICA8L2dydW5ubGFn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udD5Nb3RvcmVmZmVrdCBTdW08L2tvbXBvbmVudD4KICAgICAgICA8YmVsb2VwPjAuMDA8L2JlbG9lcD4KICAgIDwvYXZnaWZ0c2tvbXBvbmVudD4KICAgIDxhdmdpZnRza29tcG9uZW50PgogICAgICAgIDxrb21wb25lbnQ+Tk94IFN1bTwva29tcG9uZW50PgogICAgICAgIDxiZWxvZXA+NDIxMy4yNDwvYmVsb2VwPgogICAgPC9hdmdpZnRza29tcG9uZW50PgogICAgPGF2Z2lmdHNrb21wb25lbnQ+CiAgICAgICAgPGtvbXBvbmVudD5TbGFndm9sdW0gU3VtPC9rb21wb25lbnQ+CiAgICAgICAgPGJlbG9lcD4wLjAwPC9iZWxvZXA+CiAgICA8L2F2Z2lmdHNrb21wb25lbnQ+CiAgICA8YXZnaWZ0c2tvbXBvbmVudD4KICAgICAgICA8a29tcG9uZW50PlZyYWtwYW50PC9rb21wb25lbnQ+CiAgICAgICAgPGJlbG9lcD4yNDAwPC9iZWxvZXA+CiAgICA8L2F2Z2lmdHNrb21wb25lbnQ+CiAgICA8YXZnaWZ0c2tvbXBvbmVudD4KICAgICAgICA8a29tcG9uZW50PkJydWtzZnJhZHJhZyAwJTwva29tcG9uZW50PgogICAgICAgIDxiZWxvZXA+MC4wMDwvYmVsb2VwPgogICAgPC9hdmdpZnRza29tcG9uZW50PgogICAgPGZvcmhhYW5kc2JlcmVnbmluZz5mYWxzZTwvZm9yaGFhbmRzYmVyZWduaW5nPgo8L21vdG9ydm9nbmF2Z2lmdD4K"
  },
  "extension": null,
  "skjemaversjon": "v3_0"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;bjornmy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 12:24:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298536#M219225</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-24T12:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298541#M219228</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78963"&gt;@bjornmy&lt;/a&gt;&amp;nbsp; thanks for the updated info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears like you are using replaceText to replace the content of the flowfile with just the ${inn hold}. &amp;nbsp;This over writes the existing flowfile content (entire original json object) with just the encoded data.content value, which you decode, and then convert to Json.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have suggested is that you do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EvaluateJson -&amp;gt; UpdateAttribute (decode here) -&amp;gt; AttributesToJson (choose to flowfile-content) -&amp;gt; PutS3Object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will eliminate the replaceText and base64Decode processors and still give you decoded xml for the content object as json. &amp;nbsp; &amp;nbsp; &amp;nbsp; Next, &amp;nbsp;you can decide to complete this same process for the rest of the original json object. &amp;nbsp;For example, &amp;nbsp;if you want header or metadata from the original json in the S3Object. &amp;nbsp;You add these values to the EvaluateJson, get the data to attributes, then in attributesToJson you send multiple original attributes with the decoded attribute. &amp;nbsp; If you complete all the data values you would end up with exact same json object w/ the decoded XML. &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way you have it now, and the way I suggest are just two ways to do this. &amp;nbsp;Neither is right or wrong mine just gives you the ability to break down the entire object and rebuild the original json with your modification. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may also want to look into JoltTransform and/or UpdateRecord. &amp;nbsp;I do not have much experience with Jolt but you may find it can also accomplish a similar process and act only on data.content versus parsing large xml to an attribute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.10.0/org.apache.nifi.processors.standard.JoltTransformJSON/" target="_blank"&gt;https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.10.0/org.apache.nifi.processors.standard.JoltTransformJSON/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.11.4/org.apache.nifi.processors.standard.UpdateRecord/index.html" target="_blank"&gt;http://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.11.4/org.apache.nifi.processors.standard.UpdateRecord/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 12:25:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298541#M219228</guid>
      <dc:creator>stevenmatison</dc:creator>
      <dc:date>2020-06-24T12:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298552#M219234</link>
      <description>&lt;P&gt;Thanks for the quick response &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/60150"&gt;@stevenmatison&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I am not getting the expected result (yet) in that the XML-code is in my resulting file?&lt;/P&gt;&lt;P&gt;I left the EvaluateJson as above.&lt;/P&gt;&lt;P&gt;In the UpdateAttribute I set content to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;${innhold:base64Decode()}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and in the AttributesToJson I did this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bjornmy_2-1593005277954.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28068i12C1456899DFD1A8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bjornmy_2-1593005277954.png" alt="bjornmy_2-1593005277954.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The result is a json-fil with one attribute "content", and this attribute contains the whole XML-file.&lt;/P&gt;&lt;P&gt;Where did I go wrong here?&lt;/P&gt;&lt;P&gt;So the flow now looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bjornmy_0-1593005492239.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/28069i3C630A5BD8248C20/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bjornmy_0-1593005492239.png" alt="bjornmy_0-1593005492239.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;bjornmy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:31:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298552#M219234</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-24T13:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298556#M219237</link>
      <description>&lt;P&gt;That is what I would have expected based on the explanation. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What was your expected outcome? &amp;nbsp; &amp;nbsp;That would help me make a further suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:40:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298556#M219237</guid>
      <dc:creator>stevenmatison</dc:creator>
      <dc:date>2020-06-24T13:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298560#M219240</link>
      <description>&lt;P&gt;Ah, ok.&lt;/P&gt;&lt;P&gt;My aim is to convert the XML to JSON and insert the converted JSON back into the original main JSON-document in place of the coded value for the content.&lt;/P&gt;&lt;P&gt;If you take a look at the test JSON-file in my previous comment, there you will see the base64coded-value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to end up with a similar document but in stead of the base64coded-value I want to insert the Json equivalent of the XML-document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On other words I would like to end up with this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "header": {
    "dokumentidentifikator": null,
    "dokumentidentifikatorV2": "dcff985b-c652-4085-b8f1-45a2f4b6d150",
    "revisjonsnummer": 1,
    "dokumentnavn": "Engangsavgiftfastsettelse:1122334455:44BIL1:2017-10-20",
    "dokumenttype": "SKATTEMELDING_ENGANGSAVGIFT",
    "dokumenttilstand": "OPPRETTET",
    "gyldig": true,
    "gjelderInntektsaar": 2017,
    "gjelderPeriode": "2017_10",
    "gjelderPart": {
      "partsnummer": 5544332211,
      "identifiseringstype": "MASKINELL",
      "identifikator": null
    },
    "opphavspart": {
      "partsnummer": 5544332211,
      "identifikator": null
    },
    "kildereferanse": {
      "kildesystem": "ENGANGSAVGIFTFASTSETTELSE",
      "gruppe": "",
      "referanse": "aef147fb-8ce8-43ef-833b-7aa3bac1ece0",
      "tidspunkt": "2018-01-16T13:28:02.49+01:00"
    }
  },
  "data": {
    "metadata": {
      "format": "motorvogn:motorvognavgift:v1",
      "bytes": 4420,
      "mimeType": "application/xml",
      "sha1": "c0AowOsTdNdo6VufeSsZqTphc0Y="
    },
    "content": "{
  "avgiftslinje": {
    "avgiftsbeloep": 542896.0,
    "avgiftsopplysning": {
      "saeravgiftTypekode": "BB",
      "saeravgiftGruppekode": "X"
    },
    "avgiftsdato": "2017-10-20"
  },
  "betalingsinformasjon": {
    "kidnummer": 101010101010,
    "forfallsdato": "2017-10-20",
    "fakturadato": "2017-10-20",
    "totalAvgiftsbeloep": 542896.0
  },
  "motorvognavgiftstype": "engangsavgift",
  "tidsstempel": "2018-01-16+01:00",
  "grunnlagForMotorvognavgift": {
    "kjoeringensArt": 10,
    "kjoeretoey": {
      "eierskapRegistrert": "2017-10-20",
      "foersteRegistreringsaar": 2017,
      "foersteRegistreringsdatoINorge": "2017-10-20",
      "kjoeretoeygruppe": 101,
      "lengde": 3964,
      "motoreffekt": 96,
      "slagvolum": 143,
      "drivstoff": "BENSIN",
      "egenvekt": 1519,
      "eier": {
        "foedselsEllerDnummer": 1122334455,
        "partsnummer": 5544332211,
        "navn": "KLARA KU"
      },
      "tillattTotalvekt": 2164,
      "hybrid": "nei",
      "co2utslipp": 268,
      "noxutslipp": 59.4,
      "kjoeretoeyidentifikator": {
        "kjoeretoeyUnikIdentifikator": "ABCDEFGHIJ",
        "kjennemerke": "44BIL1",
        "understellsnummer": "UNDERSTELL44"
      }
    }
  },
  "avgiftspliktig": {
    "foedselsEllerDnummer": 1122334455,
    "partsnummer": 5544332211
  },
  "avgiftskomponent": [
    {
      "komponent": "Co2",
      "beloep": 475337.2
    },
    {
      "komponent": "Egenvekt",
      "beloep": 60945.64
    },
    {
      "komponent": "Motoreffekt",
      "beloep": 0.0
    },
    {
      "komponent": "NOx",
      "beloep": 4213.24
    },
    {
      "komponent": "Slagvolum",
      "beloep": 0.0
    },
    {
      "komponent": "Co2 Fratrekk",
      "beloep": 0.0
    },
    {
      "komponent": "Egenvekt Fratrekk",
      "beloep": 0.0
    },
    {
      "komponent": "Motoreffekt Fratrekk",
      "beloep": 0.0
    },
    {
      "komponent": "NOx Fratrekk",
      "beloep": 0.0
    },
    {
      "komponent": "Slagvolum Fratrekk",
      "beloep": 0.0
    },
    {
      "komponent": "Co2 Sum",
      "beloep": 475337.2
    },
    {
      "komponent": "Egenvekt Sum",
      "beloep": 60945.64
    },
    {
      "komponent": "Motoreffekt Sum",
      "beloep": 0.0
    },
    {
      "komponent": "NOx Sum",
      "beloep": 4213.24
    },
    {
      "komponent": "Slagvolum Sum",
      "beloep": 0.0
    },
    {
      "komponent": "Vrakpant",
      "beloep": 2400
    },
    {
      "komponent": "Bruksfradrag 0%",
      "beloep": 0.0
    }
  ],
  "forhaandsberegning": false
}"
  },
  "extension": null,
  "skjemaversjon": "v3_0"
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:53:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298560#M219240</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-24T13:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298561#M219241</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78963"&gt;@bjornmy&lt;/a&gt;&amp;nbsp; &amp;nbsp;Ok I understand. &amp;nbsp;In this case, you have to finish all of the json object values to attributes and then back to json, not just content. &amp;nbsp;I was using only that one as an example, and because in the original flow you were only sending content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think its best at this point to investigate the other two methods (JOLTTransform or UpdateRecord) as they should require less work handling all the other values. &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:55:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298561#M219241</guid>
      <dc:creator>stevenmatison</dc:creator>
      <dc:date>2020-06-24T13:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298564#M219244</link>
      <description>&lt;P&gt;Ok, thanks. I will start looking at these.&lt;/P&gt;&lt;P&gt;My first thought when I started this was to isolate the decoding/conversion.&amp;nbsp; Then I was hoping to find a solution where I could simply replace the "content"-value from the original file with the decoded/converted value.&amp;nbsp; But I never got farther than decoding/converting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 14:04:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/298564#M219244</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-06-24T14:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/299266#M219600</link>
      <description>&lt;P&gt;Just a short update.&lt;/P&gt;&lt;P&gt;I solved this by using the ExecueGroovyScript process and made a short groovy-script that took care of the transformation.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2020 12:36:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/299266#M219600</guid>
      <dc:creator>bjornmy</dc:creator>
      <dc:date>2020-07-07T12:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi - Decoding a base64-field in JSON and replacing the coded value with the decoded?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/374523#M242020</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78963"&gt;@bjornmy&lt;/a&gt;&amp;nbsp;I am looking to resolve the same kind of issue do you have the&amp;nbsp;&lt;SPAN&gt;groovy-script to share?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Vasu&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 20:58:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Decoding-a-base64-field-in-JSON-and-replacing-the-coded/m-p/374523#M242020</guid>
      <dc:creator>Vasu_</dc:creator>
      <dc:date>2023-07-26T20:58:57Z</dc:date>
    </item>
  </channel>
</rss>

