<?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: JSON Normalize fails for Nested Json array in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673419#M4754852</link>
    <description>&lt;P&gt;Thanks alot for your kind reply &lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt; this really helps and thanks for valuable inputs : )&lt;/P&gt;&lt;P&gt;As mentioned above I actually wanted to update like below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For  message.source IF type = '&lt;STRONG&gt;ordersEstimated&lt;/STRONG&gt;' THEN update&lt;STRONG&gt; message.source.timeStamp1 &lt;/STRONG&gt;and &lt;STRONG&gt;message.source.type1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;IF type = '&lt;B&gt;ordersCreated&lt;/B&gt;' THEN update &lt;B&gt;message.source.timeStamp2&lt;/B&gt; and &lt;B&gt;message.source.type2          ~ this is &lt;/B&gt;&lt;STRONG&gt;needed&lt;/STRONG&gt;&lt;B&gt; because no duplicate column names in hana db.&lt;/B&gt;&lt;/P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;I&gt;&lt;/I&gt;&lt;P&gt;&lt;B&gt; Is this possible &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;  &lt;/B&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For message.time IF typeId = '&lt;STRONG&gt;actual&lt;/STRONG&gt;' THEN update &lt;STRONG&gt;message.time.timeStamp&lt;/STRONG&gt; and &lt;STRONG&gt;message.time.typeId&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2023 19:09:45 GMT</pubDate>
    <dc:creator>rajeshps</dc:creator>
    <dc:date>2023-05-19T19:09:45Z</dc:date>
    <item>
      <title>JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaq-p/12673415</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;
  &lt;P&gt;For below nested json, the array is not getting normalized using&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;import pandas as pd&lt;BR /&gt;import json&lt;/P&gt;
  &lt;P&gt;def on_input(data):&lt;/P&gt;
  &lt;P&gt;df = pd.read_json(data)df = pd.json_normalize(json.loads(data))&lt;/P&gt;
  &lt;P&gt;api.send("output", df.to_json(orient="records"))&lt;/P&gt;
  &lt;P&gt;api.set_port_callback("input1", on_input)&lt;/P&gt;
  &lt;P&gt;I also tried max_level and then record_path but no luck.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Flow&lt;/STRONG&gt;: Kafka producer(json string) -&amp;gt; avro decoder -&amp;gt; Python3 -&amp;gt; Hana Client&lt;/P&gt;
  &lt;P&gt;Is there any way to normalise the json to check iF Then else condition &amp;amp; then updated suffix for column field and eventually updated to DB with no duplicates. Here header.poNumber and data.id are primary keys/unique identifiers.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt; [
   {
      "header.poNumber":"9023496",
      "data.id":"10013459",
      "message.source":[
         {
            "createSource":null,
            "timeStamp":"2023-05-12T19:30:00.0000000+02:00",
            "type":"full"
         },
         {
            "createSource":"testdev",
            "timeStamp":"2023-05-11T19:30:00.0000000+02:00",
            "type":"ordersEstimated"
         },
         {
            "createSource": "event",
            "timeStamp":"2023-05-12T12:30:00.0000000+01:00",
            "type":"ordersCreated"
         }
      ],
      "message.time":[
         {
            "timeSource":"UTC",
            "typeId":"full"
         },
         {
            "timeSource":"IST",
            "typeId":"actual"
         }
      ]
   }
]&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;STRONG&gt;Expected output:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168003-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 09:31:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaq-p/12673415</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-18T09:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673416#M4754849</link>
      <description>&lt;P&gt;I do not think you can simply normalize this record because it contains two arrays of dictionaries: `"message.time"` and `"message.source"`.&lt;/P&gt;&lt;P&gt;From the "expected output", I understand that you want to join values from `"message.time"` to values from `"message.source"` on the `type` attribute to create records.&lt;/P&gt;&lt;P&gt;So, I think you need to flatten two arrays into separate Pandas DataFrames, and then merge them on keys. Something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data_as_json=json.loads(data)&amp;lt;br&amp;gt;df_source=pd.json_normalize(data_as_json, record_path='message.source', meta=['header.poNumber', 'data.id'])
df_time=pd.json_normalize(data_as_json, record_path='message.time', meta=['header.poNumber', 'data.id'])
df=df_source.merge(df_time, left_on=['header.poNumber','data.id','type'], right_on=['header.poNumber','data.id','typeId'])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here are my tests:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2167976-image.png" /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;-Vitaliy&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 21:19:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673416#M4754849</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-18T21:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673417#M4754850</link>
      <description>&lt;P&gt;Thanks alot for your kind reply &lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;. Output i'm expecting only one row as mentioned above. &lt;/P&gt;&lt;P&gt;While normalizing consider message.source IF type = 'ordersEstimated' THEN update message.source.timeStamp1 and message.source.type1&lt;/P&gt;&lt;P&gt; IF type = 'ordersCreated' THEN update message.source.timeStamp2 and message.source.type2&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;similarly for message.time IF typeId = '&lt;STRONG&gt;actual&lt;/STRONG&gt;' THEN update message.time.timeStamp and message.time.typeId&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;strong&amp;gt;header.poNumber', &amp;lt;/strong&amp;gt;&amp;lt;strong&amp;gt;'data.id'&amp;lt;/strong&amp;gt; are primary keys so no duplicates when updating to HANA Database. Above is one event (1 record)&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;Flow looks like Kafka producer -&amp;gt; avro decoder -&amp;gt; python3 -&amp;gt; hana client&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;
&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 05:47:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673417#M4754850</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-19T05:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673418#M4754851</link>
      <description>&lt;P&gt;If you need &lt;STRONG&gt;to keep 'actual' only&lt;/STRONG&gt;, then one of the approaches might be filtering the JSON payload to keep only `actual` parts.&lt;/P&gt;&lt;P&gt;Then it is simple enough to flatten it in Pandas DataFrame.&lt;/P&gt;&lt;P&gt;Something like...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data_as_json=json.loads(data)&lt;BR /&gt;data_as_json_filtered=list()&lt;BR /&gt;for record in data_as_json:&lt;BR /&gt;    record_filtered=dict()&lt;BR /&gt;    for key in list(record.keys()):&lt;BR /&gt;        if key=='message.time':&lt;BR /&gt;            record_filtered.update({key: item for item in [time for time in record[key]] &lt;BR /&gt;                     if item['typeId']=='actual'})&lt;BR /&gt;        elif key=='message.source':&lt;BR /&gt;            record_filtered.update({key: item for item in [source for source in record[key]] &lt;BR /&gt;                     if item['type']=='actual'})&lt;BR /&gt;        else:&lt;BR /&gt;            record_filtered.update({key: record[key]})&lt;BR /&gt;    data_as_json_filtered.append(record_filtered)&lt;BR /&gt;display(data_as_json_filtered)&lt;BR /&gt;df_source=pd.json_normalize(data_as_json_filtered)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...gives me&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168029-image.png" /&gt;&lt;/P&gt;&lt;P&gt;PS. Please mark the answer as Accepted or Helpful to help the rest of the community. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 15:14:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673418#M4754851</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-19T15:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673419#M4754852</link>
      <description>&lt;P&gt;Thanks alot for your kind reply &lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt; this really helps and thanks for valuable inputs : )&lt;/P&gt;&lt;P&gt;As mentioned above I actually wanted to update like below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;For  message.source IF type = '&lt;STRONG&gt;ordersEstimated&lt;/STRONG&gt;' THEN update&lt;STRONG&gt; message.source.timeStamp1 &lt;/STRONG&gt;and &lt;STRONG&gt;message.source.type1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;IF type = '&lt;B&gt;ordersCreated&lt;/B&gt;' THEN update &lt;B&gt;message.source.timeStamp2&lt;/B&gt; and &lt;B&gt;message.source.type2          ~ this is &lt;/B&gt;&lt;STRONG&gt;needed&lt;/STRONG&gt;&lt;B&gt; because no duplicate column names in hana db.&lt;/B&gt;&lt;/P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;I&gt;&lt;/I&gt;&lt;P&gt;&lt;B&gt; Is this possible &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;  &lt;/B&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For message.time IF typeId = '&lt;STRONG&gt;actual&lt;/STRONG&gt;' THEN update &lt;STRONG&gt;message.time.timeStamp&lt;/STRONG&gt; and &lt;STRONG&gt;message.time.typeId&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 19:09:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673419#M4754852</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-19T19:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673420#M4754853</link>
      <description>&lt;P&gt;Please check if this looks good  &lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;I&gt;&lt;/I&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
import json

def on_input(data):
  data_as_json=json.loads(data)

  data_as_json_filtered=list()
  for record in data_as_json:
     record_filtered=dict()
     for key in list(record.keys()):
         if key=='message.time':
             record_filtered.update({key: item for item in [time for time in record[key]] 
                      if item['typeId']=='actual'})
         elif key=='message.source':
             record_filtered.update({key: item for item in [source for source in record[key]] 
                      if item['type']=='actual'})
         else:
             record_filtered.update({key: record[key]})
     data_as_json_filtered.append(record_filtered)
  display(data_as_json_filtered)

  df_source=pd.json_normalize(data_as_json_filtered)

  api.send("output", df_source.to_json(orient="records"))

api.set_port_callback("input1", on_input)&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks you very much!&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 19:14:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673420#M4754853</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-19T19:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673421#M4754854</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
import json

def on_input(data):
    data_as_json = json.loads(data)
    data_as_json_filtered=list()
    for record in data_as_json:
        record_filtered = dict()
        for key in list(record.keys()):
            if key=='message.time':
                record_filtered.update({key: item for item in [time for time in record[key]] 
                        if item['typeId']=='actual'})
            elif key=='message.source':
                record_filtered.update({key: item for item in [source for source in record[key]] 
                          if item['type']=='actual'})
            else:
                record_filtered.update({key: record[key]})
        data_as_json_filtered.append(record_filtered)
    df_source=pd.json_normalize(data_as_json_filtered)
    api.send("output", df_source.to_json(orient="records"))
api.set_port_callback("input1", on_input)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;EM&gt;It is failing at   &lt;B&gt;for key in list(record.keys()) &lt;/B&gt;with below error&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;P&gt;&lt;STRONG&gt;Group messages:&lt;/STRONG&gt;&lt;/P&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;P&gt;&lt;STRONG&gt;Group: default; Messages: Graph failure: operator.com.sap.system.python3Operator:python3operator1: Error while executing callback registered on port(s) ['input1']: 'str' object has no attribute 'keys' [line 10]&lt;/STRONG&gt;&lt;/P&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;P&gt;&lt;STRONG&gt;Process(es) terminated with error(s). restartOnFailure==false&lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/EM&gt;&lt;A href="https://answers.sap.com/storage/temp/2168056-error123.png" data-attachment="2168056"&gt;error123.png&lt;/A&gt;&lt;P&gt;input is json string and outpus is basic string in Python3 operator&lt;/P&gt;&lt;P&gt;Please require your valuable inputs and support. Thank you &lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;I&gt;&lt;/I&gt;&lt;I&gt;&lt;BR /&gt;&lt;/I&gt;</description>
      <pubDate>Sun, 21 May 2023 16:13:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673421#M4754854</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-21T16:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673422#M4754855</link>
      <description>&lt;P&gt;Hi Rajesh,&lt;/P&gt;&lt;P&gt;Do you have an exact value of the `data` that is sent to the input of the `on_input(data)`?&lt;/P&gt;&lt;P&gt;It might be different from the one you shared in the example.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;-Witalij&lt;/P&gt;</description>
      <pubDate>Sun, 21 May 2023 20:30:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673422#M4754855</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-21T20:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673423#M4754856</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Below is the data sent to python 3 operator input 1 as json string. This needs filtering and then updated to database table with no duplicate columns.&lt;/P&gt;&lt;P&gt; poNumber and id are primary keys/uinque identifiers at each row. Thankyou!&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;{
   "header":{
      "poNumber":"9023496"
   },
   "data":{
      "id":"10013459"
   },
   "message":{
      "source":[
         {
            "createSource":null,
            "timeStamp":"2023-05-12T19:30:00.0000000+02:00",
            "type":"full"
         },
         {
            "createSource":"testdev",
            "timeStamp":"2023-05-11T19:30:00.0000000+02:00",
            "type":"ordersEstimated"
         },
         {
            "createSource":"event",
            "timeStamp":"2023-05-12T12:30:00.0000000+01:00",
            "type":"ordersCreated"
         }
      ],
      "time":[
         {
            "timeSource":"UTC",
            "typeId":"full"
         },
         {
            "timeSource":"IST",
            "typeId":"actual"
         }
      ]
   }
}&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 May 2023 20:47:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673423#M4754856</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-21T20:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673424#M4754857</link>
      <description>&lt;P&gt;There two JSON documents have different formatting:&lt;/P&gt;&lt;P&gt;1/ The first one was an array starting with `[`, while the second one is not as it is a dictionary starting with `{`&lt;/P&gt;&lt;P&gt;2/ The first one had `"message"` keys already flattened, while the second has them nested.&lt;/P&gt;&lt;P&gt;So, following the same idea from my previous code snippet, you need to re-write it to properly process the structure you are getting on the input.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;-Witalij&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 13:09:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673424#M4754857</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-22T13:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673425#M4754858</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;vitaliy.rudnytskiy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Could you please help me with he snippet. I tried and getting below error&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Failing at &lt;STRONG&gt;for key in list(record.keys()) &lt;/STRONG&gt;with below error&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Group: default; Messages: Graph failure: operator.com.sap.system.python3Operator:python3operator1: Error while executing callback registered on port(s) ['input1']: 'str' object has no attribute 'keys' [line 10]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thankyou much in advance !&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 13:15:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673425#M4754858</guid>
      <dc:creator>rajeshps</dc:creator>
      <dc:date>2023-05-22T13:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673426#M4754859</link>
      <description>&lt;P&gt;As I wrote above: you do not have an array of records in the later JSON example, compared to the JSON in the original question. Therefore you do not loop through records.&lt;/P&gt;&lt;P&gt;In a sample snippet (but you need to review it and -- first of all -- fix the exact schema JSON payload is coming to your operator to make sure it is not failing):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;record_filtered=dict()&lt;BR /&gt;record = data_as_json&lt;BR /&gt;for key1 in list(record.keys()):&lt;BR /&gt;    if key1=='message':&lt;BR /&gt;        msg_filtered=dict()&lt;BR /&gt;        for key2 in record[key1].keys():&lt;BR /&gt;            if key2=='time':&lt;BR /&gt;                msg_filtered.update({key2: item &lt;BR /&gt;                                     for item in [time for time in record[key1][key2]] &lt;BR /&gt;                                     if item['typeId']=='actual'}&lt;BR /&gt;                                   )&lt;BR /&gt;            elif key2=='source':&lt;BR /&gt;                msg_filtered.update({key2: item &lt;BR /&gt;                                     for item in [source for source in record[key1][key2]]&lt;BR /&gt;                                     if item['type']=='actual'}&lt;BR /&gt;                                   )&lt;BR /&gt;            else: pass&lt;BR /&gt;        record_filtered.update({key1: msg_filtered})&lt;BR /&gt;    else:&lt;BR /&gt;        record_filtered.update({key1: record[key1]})&lt;BR /&gt;data_as_json_filtered=record_filtered&lt;BR /&gt;display(data_as_json_filtered)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2168125-image.png" /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;-Witalij&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 15:09:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673426#M4754859</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-22T15:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Normalize fails for Nested Json array</title>
      <link>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673427#M4754860</link>
      <description>&lt;P&gt;Can you please accept the answer, if it helped, and mark your question as answered? Thank you. -Witalij&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 17:26:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/json-normalize-fails-for-nested-json-array/qaa-p/12673427#M4754860</guid>
      <dc:creator>Vitaliy-R</dc:creator>
      <dc:date>2023-05-24T17:26:51Z</dc:date>
    </item>
  </channel>
</rss>

