title: Create/ re-create a list of dictionaries from a dictionary via Python Recursion function
body: <p>So, I'm trying to parse this json object into multiple events, as it's the expected input for a ETL tool. I know this is quite straight forward if we do this via loops, if statements and explicitly defining the search fields for given events. This method is not feasible because I have multiple heavily nested JSON objects and I would prefer to let the python recursions handle the heavy lifting. The following is a sample object, which consist of string, list and dict (basically covers most use-cases, from the data I have).</p>
  <pre><code>{
  &quot;event_name&quot;: &quot;restaurants&quot;,
  &quot;properties&quot;: {
      &quot;_id&quot;: &quot;5a9909384309cf90b5739342&quot;,
      &quot;name&quot;: &quot;Mangal Kebab Turkish Restaurant&quot;,
      &quot;restaurant_id&quot;: &quot;41009112&quot;,
      &quot;borough&quot;: &quot;Queens&quot;,
      &quot;cuisine&quot;: &quot;Turkish&quot;,
      &quot;address&quot;: {
          &quot;building&quot;: &quot;4620&quot;,
          &quot;coord&quot;: {
              &quot;0&quot;: -73.9180155,
              &quot;1&quot;: 40.7427742
          },
          &quot;street&quot;: &quot;Queens Boulevard&quot;,
          &quot;zipcode&quot;: &quot;11104&quot;
      },
      &quot;grades&quot;: [
           {
              &quot;date&quot;: 1414540800000,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;score&quot;: 12
          },
          {
              &quot;date&quot;: 1397692800000,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;score&quot;: 10
          },
          {
              &quot;date&quot;: 1381276800000,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;score&quot;: 12
          }
      ]
  }
  }
  </code></pre>
  <p>And I want to convert it to this following list of dictionaries</p>
  <pre><code>[
      {
          &quot;event_name&quot;: &quot;restaurants&quot;,
              &quot;properties&quot;: {
              &quot;restaurant_id&quot;: &quot;41009112&quot;,
              &quot;name&quot;: &quot;Mangal Kebab Turkish Restaurant&quot;,
              &quot;cuisine&quot;: &quot;Turkish&quot;,
              &quot;_id&quot;: &quot;5a9909384309cf90b5739342&quot;,
              &quot;borough&quot;: &quot;Queens&quot;
          }
      },
      {
          &quot;event_name&quot;: &quot;restaurant_address&quot;,
          &quot;properties&quot;: {
              &quot;zipcode&quot;: &quot;11104&quot;,
              &quot;ref_id&quot;: &quot;41009112&quot;,
              &quot;street&quot;: &quot;Queens Boulevard&quot;,
              &quot;building&quot;: &quot;4620&quot;
          }
      },
      {
          &quot;event_name&quot;: &quot;restaurant_address_coord&quot;
          &quot;ref_id&quot;: &quot;41009112&quot;
          &quot;0&quot;: -73.9180155,
          &quot;1&quot;: 40.7427742
      },
      {
          &quot;event_name&quot;: &quot;restaurant_grades&quot;,
          &quot;properties&quot;: {
              &quot;date&quot;: 1414540800000,
              &quot;ref_id&quot;: &quot;41009112&quot;,
              &quot;score&quot;: 12,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;index&quot;: &quot;0&quot;
          }
      },
      {
          &quot;event_name&quot;: &quot;restaurant_grades&quot;,
          &quot;properties&quot;: {
              &quot;date&quot;: 1397692800000,
              &quot;ref_id&quot;: &quot;41009112&quot;,
              &quot;score&quot;: 10,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;index&quot;: &quot;1&quot;
          }
      },
      {
          &quot;event_name&quot;: &quot;restaurant_grades&quot;,
          &quot;properties&quot;: {
              &quot;date&quot;: 1381276800000,
              &quot;ref_id&quot;: &quot;41009112&quot;,
              &quot;score&quot;: 12,
              &quot;grade&quot;: &quot;A&quot;,
              &quot;index&quot;: &quot;2&quot;
          }
      }
  ]
  </code></pre>
  <p>And most importantly these events will be broken up into independent structured tables to conduct joins, we need to create primary keys/ unique identifiers. So the deeply nested dictionaries should have its corresponding parents_id field as ref_id. In this case ref_id = restaurant_id from its parent dictionary.</p>
  <p>Most of the example on the internet flatten's the whole object to be normalized and into a dataframe, but to utilise this ETL tool to its full potential it would be ideal to solve this problem via recursions and outputting as list of dictionaries.</p>