<?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 can i parse string nested json  with Nifi? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385996#M245923</link>
    <description>&lt;P&gt;Can you send the JOLT just to understand what you are exactly extracting?&lt;/P&gt;&lt;P&gt;for example if you are extracting&amp;nbsp;@value&amp;nbsp; then something like&amp;nbsp;&lt;SPAN&gt;"@value": "=toInteger" in JOLT can be written for typeconversion.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I belive type conversion can not be done in list.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 19:46:39 GMT</pubDate>
    <dc:creator>saquibsk</dc:creator>
    <dc:date>2024-04-03T19:46:39Z</dc:date>
    <item>
      <title>How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385864#M245859</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a JSON data in the ClickHouse database with a type of string. The JSON data looks like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}}" }]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output I get using Nifida ExecuteSqlRecord is like this. I can remove the \ character using the ReplaceText process. The output looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}}" }]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the value part for the content key is still a string. How can I make its type as JSON?&lt;/P&gt;&lt;P&gt;The desired output is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": {"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}} }]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 08:25:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385864#M245859</guid>
      <dc:creator>mstfo</dc:creator>
      <dc:date>2024-04-02T08:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385887#M245866</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95643"&gt;@mstfo&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Take the output to UpdateRecord processor, and cast the desire field to any specific data type example&lt;/P&gt;&lt;P&gt;formula: ${field.value:ToInteger()}&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 14:48:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385887#M245866</guid>
      <dc:creator>saquibsk</dc:creator>
      <dc:date>2024-04-02T14:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385918#M245881</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am currently using the 'executesqlrecord -&amp;gt; replacetext' (for unescapeJson) process. How should I use the 'updateRecord' processor here? Could you explain a bit more ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 06:50:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385918#M245881</guid>
      <dc:creator>mstfo</dc:creator>
      <dc:date>2024-04-03T06:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385926#M245886</link>
      <description>&lt;P&gt;Are you fetching and processing the records as it is ? or defining the json path (flatting the JSON) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}}" }]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 07:56:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385926#M245886</guid>
      <dc:creator>saquibsk</dc:creator>
      <dc:date>2024-04-03T07:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385930#M245889</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The content field in the source table is in string format. When I receive the data from the source, it comes like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057" }}]}}" }]&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;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dark bg-gray-950 rounded-md"&gt;&lt;DIV class="p-4 overflow-y-auto"&gt;&lt;SPAN&gt;After I fetch this data with NiFi, I need to use a Jolt transformation on the content field, but since the content field is in string format, I can't perform the transformation. My actual problem is to eliminate the string expression in the content field and convert it to the following format so that I can use Jolt for the content field:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="p-4 overflow-y-auto"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="p-4 overflow-y-auto"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": {"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}} }]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 08:45:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385930#M245889</guid>
      <dc:creator>mstfo</dc:creator>
      <dc:date>2024-04-03T08:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385996#M245923</link>
      <description>&lt;P&gt;Can you send the JOLT just to understand what you are exactly extracting?&lt;/P&gt;&lt;P&gt;for example if you are extracting&amp;nbsp;@value&amp;nbsp; then something like&amp;nbsp;&lt;SPAN&gt;"@value": "=toInteger" in JOLT can be written for typeconversion.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I belive type conversion can not be done in list.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 19:46:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/385996#M245923</guid>
      <dc:creator>saquibsk</dc:creator>
      <dc:date>2024-04-03T19:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/386101#M245940</link>
      <description>&lt;P&gt;"This is the output I obtained with executesqlrecord: [{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057" }}]}}" }] After executesqlrecord, I use ${'$1':unescapeJson()} in the replacetext processor to remove the backslash characters. Then my output looks like this: [{ "Name": "Gta V" "Type": "Xyz" "content": "{"Game":{"Subject":[{"Time":{"@value":"201511021057" }}]}}" }]&lt;/P&gt;&lt;P&gt;What I want is, after removing the backslashes, the nested JSON data in the content field should not come within double quotes. I want to learn the ways to remove it after ReplaceText. So, ultimately, the desired output is:&lt;/P&gt;&lt;P&gt;[{ "Name": "Gta V" "Type": "Xyz" "content": {"Game":{"Subject":[{"Time":{"@value":"201511021057"}}]}} }]&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 11:31:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/386101#M245940</guid>
      <dc:creator>mstfo</dc:creator>
      <dc:date>2024-04-04T11:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can i parse string nested json  with Nifi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/388810#M246791</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95643"&gt;@mstfo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Firstly it seems that the output you have after the replacetext processor isn't really a json, because of the missing commas (' , ') between the fields.&lt;/P&gt;&lt;P&gt;If your output is exactly like this, it will be necessary to add those missing commas so then you can get a json like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "Name": "Gta V",
    "Type": "Xyz",
    "content": "{\"Game\":{\"Subject\":[{\"Time\":{\"@value\":\"201511021057\" }}]}}"
  }
]&lt;/LI-CODE&gt;&lt;P&gt;To obtain a json like this you can either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;try to change the logic when you get the data from the database;&lt;/LI&gt;&lt;LI&gt;try to add the commas manually.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The first option is the quicker solution, but there is the possibility that maybe you can't change the input you receive from the db, so perhaps you have to manually change it yourself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, in case you manage to obtain a correct json from your input, then you can manipulate the string using the functions in the beta operations in jolt (like the =split()) and then reassemble the wanted json.&lt;BR /&gt;&lt;BR /&gt;I wrote a guide and in the very last example i did, there is a similar case, so if you want go there and give it a look -&amp;gt; &lt;A href="https://lucabiscotti.github.io/jolt-guide.github.io/" target="_blank" rel="noopener"&gt;JOLT guide&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 15:56:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-parse-string-nested-json-with-Nifi/m-p/388810#M246791</guid>
      <dc:creator>JOLTEnjoyer</dc:creator>
      <dc:date>2024-06-05T15:56:28Z</dc:date>
    </item>
  </channel>
</rss>

