title: Flatten nested lists in dataframe after JSON import in R
body: <p>I have numerous JSON files each with many flight-data records. A record looks like the following JSON structure.</p>
  <pre class="lang-json prettyprint-override"><code>[
      {
          &quot;flight&quot;: {
              &quot;operatingAirline&quot;: {
                  &quot;iataCode&quot;: &quot;NH&quot;,
                  &quot;icaoCode&quot;: &quot;ANA&quot;,
                  &quot;airlineDisplayCode&quot;: &quot;NH&quot;,
                  &quot;name&quot;: &quot;ANA All Nippon Airways&quot;
              },
              &quot;serviceTypeCode&quot;:&quot;PP&quot;,
              &quot;aircraftType&quot;: {
                  &quot;icaoCode&quot;: &quot;B77W&quot;,
                  &quot;modelName&quot;: &quot;B77W&quot;,
                  &quot;registration&quot;: &quot;JA792A&quot;
              },
              &quot;flightNumber&quot;: {
                  &quot;airlineCode&quot;: &quot;NH&quot;,
                  &quot;trackNumber&quot;: &quot;00203&quot;,
                  &quot;suffix&quot;: &quot;&quot;
              },
              &quot;codeShares&quot;: [
                  {
                      &quot;codeShare&quot;: {
                          &quot;airlineCode&quot;: &quot;LH&quot;,
                          &quot;trackNumber&quot;: &quot;04921&quot;,
                          &quot;suffix&quot;: &quot;&quot;
                      }
                  }
              ],
              &quot;departureAirport&quot;: &quot;HND&quot;,
              &quot;arrivalAirport&quot;: &quot;FRA&quot;,
              &quot;originDate&quot;: &quot;2016-02-23&quot;,
              &quot;arrival&quot;: {
                  &quot;scheduled&quot;: &quot;2016-02-23T04:20:00Z&quot;,
                  &quot;estimated&quot;: &quot;2016-02-23T04:16:00Z&quot;,
                  &quot;actual&quot;: &quot;2016-02-23T04:16:16Z&quot;,
                  &quot;terminal&quot;: &quot;1&quot;,
                  &quot;gates&quot;: {
                      &quot;gate&quot;: &quot;B48A&quot;
                  },
                  &quot;baggageClaim&quot;: {
                      &quot;carousel&quot;: &quot;19&quot;
                  }
              },
              &quot;flightStatus&quot;: &quot;&quot;
          }
      }
  ]
  </code></pre>
  <p>But executing the following gives me a not completely flat dataframe.</p>
  <pre class="lang-r prettyprint-override"><code>library(jsonlite)
  
  df &lt;- fromJSON(paste(getwd(), &quot;test-data/arrival-2020-01-28-00-36.json&quot;, sep='/'), flatten=TRUE)
  </code></pre>
  <p>For example the columns <code>flight.codeShares</code> and <code>flight.arrival.gates</code> contain lists, which prevents the dataframe from being stored in a sqlite file. I'm looking for a solution to process a JSON file with multiple records at once.</p>
  <p>In the pyton ecosystem there is a <code>json_normalize</code> function, which does the job. How can i do this in R?</p>