Parsing the json file from gene ontology result into dataframe How do I parse the json file from ontology output.
My file json file
jdata &lt;- read_json(&quot;analysis.json&quot;, simplifyVector = TRUE)

I want to convert it into a data.frame format. I can able to take the GO term and respective p value etc. But I would like to know the genes that are getting part of the enriched list which is under the upload_1 for example under DNA Replication there are 33 terms but 8 are from my input. So my objective is to get the 8 gene so on and so forth.
So I would like to see a data.frame where I want to have GO term in the first column gene mapped into the term would be second i.e upload_[#] third one fold enrichment and last one p value.
This is how i would like to see this one is the text output in the column upload_1 (450) instead of that number i would like to see then gene names which are present in the json file.
Some progress here is my code
l &lt;- fromJSON(&quot;analysis.json&quot;)

m &lt;- lapply(
  l[[1]]$result, 
  function(x) c(x$input_list$mapped_id_list['mapped_id'], x$term['id'],x$input_list['pValue'],x$term['label'])
)
m &lt;- do.call(rbind, m)

output:
mapped_id     id           pValue       label                       
[1,] Character,8   &quot;GO:0006270&quot; 0.007540801  &quot;DNA replication initiation&quot;
[2,] Character,388 &quot;GO:0009987&quot; 3.232843e-10 &quot;cellular process&quot;          

Right now I can parse out first two row.
Things I would like to append to the code is

I would like to do for all the terms
The first column where i am trying to get all the genes now it is coming as character while number suggests gene present. That I wont need probably since i need only gene names which is being shown as character now.

dput(head(b))
    structure(list(`GO biological process complete` = c(&quot;DNA replication initiation (GO:0006270)&quot;, 
    &quot;regulation of blood coagulation (GO:0030193)&quot;, &quot;regulation of hemostasis (GO:1900046)&quot;, 
    &quot;regulation of coagulation (GO:0050818)&quot;, &quot;platelet degranulation (GO:0002576)&quot;, 
    &quot;cell cycle G1/S phase transition (GO:0044843)&quot;), `upload_1 (450)` = c(8, 
    13, 13, 13, 16, 15), `upload_1 (fold Enrichment)` = c(11.23, 
    7.09, 7, 6.62, 5.75, 5.35), `upload_1 (P-value)` = c(0.00754, 
    0.000627, 0.000716, 0.00135, 0.000347, 0.00228)), row.names = c(NA, 
    -6L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;))

Any suggestion or help would be really appreciated.
I don't know how to do that in R but I think this is what you want:
I used http://json2table.com for view the data structure of the JSON file, then I used json_normalize to normalize the JSON data into a flat table using the key [result] to a list of DataFrames for each index in the JSON file. Then, I concatenated the list of DataFrames in a single one with df.concat()
import json
import pandas as pd

with open('analysis.json') as f:
    d = json.load(f)

dfs = []
for x, y in enumerate(d):
    data = pd.json_normalize(d[x]['result'])
    dfs.append(data)

df = pd.concat(dfs, ignore_index=True)

df.to_csv('analysis.csv', index=False)