It's a little hard to know what your goal is here based on the sample code, but I do find that your JSON snippet does not match any spec. I was able to edit it to add brackets to make the entries elements of a list:
[
{
"biosample_ontology": {
"@id": "https://www.encodeproject.org/biosample-types/primary_cell_CL_0000576/",
"@type": [
"BiosampleType",
"Item"
],
"aliases": [],
"cell_slims": [
"hematopoietic cell",
"monocyte",
"myeloid cell",
"leukocyte"
],
"classification": "primary cell",
"dbxrefs": [],
"developmental_slims": [
"mesoderm"
],
"name": "primary_cell_CL_0000576",
"organ_slims": [
"blood",
"bodily fluid"
],
"references": [],
"schema_version": "1",
"status": "released",
"synonyms": [],
"system_slims": [
"immune system"
],
"term_id": "CL:0000576",
"term_name": "monocyte",
"uuid": "20685264-1187-4c5c-b4ce-dc85ea53fc11"
},
"chrom": "chr11",
"dataset": "https://www.encodeproject.org/annotations/ENCSR464XOM/",
"dataset_rel": "/annotations/ENCSR464XOM/",
"documents": [],
"end": 59936979,
"file": "ENCFF814NRI",
"method": "eQTLs",
"start": 59936978,
"strand": null,
"targets": [],
"value": "MS4A4A"
},
{
"biosample_ontology": {
"@id": "https://www.encodeproject.org/biosample-types/primary_cell_CL_0000576/",
"@type": [
"BiosampleType",
"Item"
],
"aliases": [],
"cell_slims": [
"hematopoietic cell",
"monocyte",
"myeloid cell",
"leukocyte"
],
"classification": "primary cell",
"dbxrefs": [],
"developmental_slims": [
"mesoderm"
],
"name": "primary_cell_CL_0000576",
"organ_slims": [
"blood",
"bodily fluid"
],
"references": [],
"schema_version": "1",
"status": "released",
"synonyms": [],
"system_slims": [
"immune system"
],
"term_id": "CL:0000576",
"term_name": "monocyte",
"uuid": "20685264-1187-4c5c-b4ce-dc85ea53fc11"
},
"chrom": "chr11",
"dataset": "https://www.encodeproject.org/annotations/ENCSR464XOM/",
"dataset_rel": "/annotations/ENCSR464XOM/",
"documents": [],
"end": 59936979,
"file": "ENCFF814NRI",
"method": "eQTLs",
"start": 59936979,
"strand": null,
"targets": [],
"value": "MS4A4B"
}
]
When I did this, I was able to slightly modify your code to print out each element's method
key, value pair:
import json
with open('/Users/max.press/Downloads/file.json') as f:
f_json = json.load(f)
for i in range(len(f_json)):
print(f_json[i]["method"] + "\t" + f_json[i]["value"])
% python ~/Downloads/readfile.py
# prints this:
eQTLs MS4A4A
eQTLs MS4A4B