Use the json module to produce JSON output:

import json

with open(outputfilename, 'wb') as outfile:
    json.dump(row, outfile)

This writes the JSON result directly to the file (replacing any previous content if the file already existed).

If you need the JSON result string in Python itself, use json.dumps() (added s, for 'string'):

json_string = json.dumps(row)

The L is just Python syntax for a long integer value; the json library knows how to handle those values, no L will be written.

Demo string output:

>>> import json
>>> row = [1L,[0.1,0.2],[[1234L,1],[134L,2]]]
>>> json.dumps(row)
'[1, [0.1, 0.2], [[1234, 1], [134, 2]]]'
Answer from Martijn Pieters on Stack Overflow
Discussions

Unable to append data to Json array object with desired output
I’m tried getting help for same issue on stack-overflow but got no help or replies. I’m re-posting here with the hope that someone can please guide me as I’m unable to push the code to repository due to delay. My code import json import re from http.client import responses import vt import ... More on discuss.python.org
🌐 discuss.python.org
5
0
January 18, 2023
Creating JSON Array of data with python
What I’m trying to do: I’m trying to retrieve the data from database and then create a JSON Array to send it to Google Gantt. What I’ve tried and what’s not working: I’m having propably problems with the conversion of python date to JSON date. Really I’m out of ideas how to do it ... More on anvil.works
🌐 anvil.works
1
0
August 22, 2023
python - How to convert Json to array? - Stack Overflow
I created a system with Django. In this system, I read a .xlsx file with panda and I convert it to JSON. I will make some operations and display them in my template. Because of that I want to conve... More on stackoverflow.com
🌐 stackoverflow.com
python - Read in JSON into array - Stack Overflow
Sorry I am amateur with arrays, so I'd like to know how to put all price types in their separate array variable. ... import json with open('1.json') as data_file: data = json.load(data_file) print([row['close'] for row in data]) More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python.org
discuss.python.org › python help
Unable to append data to Json array object with desired output - Python Help - Discussions on Python.org
January 18, 2023 - I’m tried getting help for same issue on stack-overflow but got no help or replies. I’m re-posting here with the hope that someone can please guide me as I’m unable to push the code to repository due to delay. My code import json import re from http.client import responses import vt import requests with open('/home/asad/Downloads/ssh-log-parser/ok.txt', 'r') as file: file = file.read() pattern = re.compile(r'\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}') ips = pattern.findall(file) unique_ips = lis...
🌐
Python Guides
pythonguides.com › json-data-in-python
How to Extract Values from a JSON Array in Python
April 27, 2026 - In this tutorial, I will show you exactly how to navigate these arrays and extract the data you need efficiently. ... In Python, when we talk about a JSON array, we are essentially dealing with a List of Dictionaries.
Top answer
1 of 3
1

I think you need data into this format

[{'Financial Ratios': 'Ratios',
  'Unnamed: 1': 'Formula ',
  'Unnamed: 2': '2013',
  'Unnamed: 3': 2012.0,
  'Unnamed: 4': 'Point',
  'Unnamed: 5': 'Max Score for the Ratio',
  'Unnamed: 6': 'Weighted Score'},
 {'Financial Ratios': 'Activity Ratios',
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': 'Total Asset Turnover Ratio',
  'Unnamed: 1': ' Sales/Total Assets (S/TA) (X5)',
  'Unnamed: 2': 0.3688805385,
  'Unnamed: 3': 0.46659987,
  'Unnamed: 4': 1,
  'Unnamed: 5': 50,
  'Unnamed: 6': 10},
 {'Financial Ratios': 'Working Capital Turnover',
  'Unnamed: 1': 'Sales/Working Capital',
  'Unnamed: 2': 1.5217292178,
  'Unnamed: 3': 2.3187325549,
  'Unnamed: 4': 0,
  'Unnamed: 5': 15,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'RiskCalc. v4. Activity Ratio 2',
  'Unnamed: 1': 'Account Payable/Sales',
  'Unnamed: 2': 0.3654207703,
  'Unnamed: 3': 0.7809577867,
  'Unnamed: 4': 1,
  'Unnamed: 5': 10,
  'Unnamed: 6': 10},
 {'Financial Ratios': 'Days of Inventory on Hand (DOH)',
  'Unnamed: 1': '365/(Cost of Goods Sold/Inventory)',
  'Unnamed: 2': 126.7687160825,
  'Unnamed: 3': 89.3996349298,
  'Unnamed: 4': 0,
  'Unnamed: 5': 5,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Days of Sales Outstanding (DSO)',
  'Unnamed: 1': '365/(Sales/Trade Receivables)',
  'Unnamed: 2': 201.1519182976,
  'Unnamed: 3': 136.5175896751,
  'Unnamed: 4': 0,
  'Unnamed: 5': 5,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Number of Days of Payables',
  'Unnamed: 1': '365/(Cost of Goods Sold/Trade Payables)',
  'Unnamed: 2': 156.6392091208,
  'Unnamed: 3': 343.2088569019,
  'Unnamed: 4': 0,
  'Unnamed: 5': 5,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Cash Conversion Cycle',
  'Unnamed: 1': 'DOH + DSO – Number of Days of Payables',
  'Unnamed: 2': 171.2814252594,
  'Unnamed: 3': -117.291632297,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': 'Efficiency Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 20},
 {'Financial Ratios': 'Liquidity Ratios',
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': 'liquidity',
  'Unnamed: 1': 'X1, Working Capital/Total Assets (WC/TA)',
  'Unnamed: 2': 0.24240879,
  'Unnamed: 3': 0.2012305684,
  'Unnamed: 4': 2,
  'Unnamed: 5': 20,
  'Unnamed: 6': 8},
 {'Financial Ratios': 'Current Ratio',
  'Unnamed: 1': 'Current Assets/Current Liabilities',
  'Unnamed: 2': 1.4011830177,
  'Unnamed: 3': 1.3122086769,
  'Unnamed: 4': 3,
  'Unnamed: 5': 40,
  'Unnamed: 6': 24},
 {'Financial Ratios': 'Quick Ratio',
  'Unnamed: 1': '(Current Assets-Inventory)/Current Liabilities',
  'Unnamed: 2': 1.2206383114,
  'Unnamed: 3': 1.1649433701,
  'Unnamed: 4': 4,
  'Unnamed: 5': 30,
  'Unnamed: 6': 24},
 {'Financial Ratios': 'Cash Ratio',
  'Unnamed: 1': 'Cash and Marketable Securities/Current Liabilities',
  'Unnamed: 2': 0.1198051849,
  'Unnamed: 3': 0.3207784969,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': 'liquidity Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 56},
 {'Financial Ratios': 'Solvency Ratios',
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': 'Solvency',
  'Unnamed: 1': 'X4, Equity/ TotalLiabilities (E/TL)',
  'Unnamed: 2': 0.2542669835,
  'Unnamed: 3': 0.3698847524,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Total Debt Ratio',
  'Unnamed: 1': 'Total Debt/Total Assets',
  'Unnamed: 2': 0.7972784209,
  'Unnamed: 3': 0.7299884156,
  'Unnamed: 4': 2,
  'Unnamed: 5': 25,
  'Unnamed: 6': 10},
 {'Financial Ratios': 'Financial Liabilities Percentage',
  'Unnamed: 1': 'short-term Financial Liabilities/Current Liabilities',
  'Unnamed: 2': 0.1830886471,
  'Unnamed: 3': 0.1413598101,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Current Liabilities to Net Worth',
  'Unnamed: 1': '(Current Liabilities/Net Worth)*100',
  'Unnamed: 2': 298.0614724129,
  'Unnamed: 3': 238.7077877629,
  'Unnamed: 4': 2,
  'Unnamed: 5': 25,
  'Unnamed: 6': 10},
 {'Financial Ratios': 'Financial Leverage Ratio',
  'Unnamed: 1': 'Total Assets/TotalEquity',
  'Unnamed: 2': 4.9328739664,
  'Unnamed: 3': 3.7035448029,
  'Unnamed: 4': 0,
  'Unnamed: 5': 5,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Financial Expense Coverage',
  'Unnamed: 1': 'Operating Profit/Total Financial Expense',
  'Unnamed: 2': 0.6270806042,
  'Unnamed: 3': 5.1835849804,
  'Unnamed: 4': 1,
  'Unnamed: 5': 25,
  'Unnamed: 6': 5},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': 'Solvency Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 25},
 {'Financial Ratios': 'Profitability Ratios',
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': 'Cumulative Profitability',
  'Unnamed: 1': 'X2, Retained Earnings/Total Assets (RE/TA)',
  'Unnamed: 2': 0.0236571651,
  'Unnamed: 3': 0.1355888945,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Gross Profit Margin',
  'Unnamed: 1': 'Gross Profit/Sales',
  'Unnamed: 2': 0.1484981192,
  'Unnamed: 3': 0.169457354,
  'Unnamed: 4': 0,
  'Unnamed: 5': 10,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Operating Profit Margin',
  'Unnamed: 1': 'Operating Profit/Sales',
  'Unnamed: 2': 0.0492337241,
  'Unnamed: 3': 0.0634190537,
  'Unnamed: 4': 0,
  'Unnamed: 5': 15,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Net Profit Margin',
  'Unnamed: 1': 'Net Profit/Sales',
  'Unnamed: 2': 0.0334269397,
  'Unnamed: 3': 0.1038080661,
  'Unnamed: 4': 0,
  'Unnamed: 5': 15,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Return on Assets-Productivity',
  'Unnamed: 1': 'X3, Operating Profit/Total Assets',
  'Unnamed: 2': 0.0181613627,
  'Unnamed: 3': 0.0295913222,
  'Unnamed: 4': 1,
  'Unnamed: 5': 25,
  'Unnamed: 6': 5},
 {'Financial Ratios': 'Return on Equity',
  'Unnamed: 1': 'Net Income/Equity',
  'Unnamed: 2': 0.0608250368,
  'Unnamed: 3': 0.1793879706,
  'Unnamed: 4': 2,
  'Unnamed: 5': 25,
  'Unnamed: 6': 10},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': 'Profitability Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 15},
 {'Financial Ratios': 'Growth',
  'Unnamed: 1': None,
  'Unnamed: 2': 'Year over year trends 2012 vs 2013',
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': 'Sales Growth',
  'Unnamed: 1': 'Annual Sales Growth',
  'Unnamed: 2': 0.121184383,
  'Unnamed: 3': None,
  'Unnamed: 4': 1,
  'Unnamed: 5': 20,
  'Unnamed: 6': 20},
 {'Financial Ratios': 'Operating Profit Growth',
  'Unnamed: 1': 'Annual Operating Profit Growth',
  'Unnamed: 2': 0.0492337241,
  'Unnamed: 3': None,
  'Unnamed: 4': 1,
  'Unnamed: 5': 20,
  'Unnamed: 6': 20},
 {'Financial Ratios': 'NetProfit Growth',
  'Unnamed: 1': 'Annual Net Profit Growth',
  'Unnamed: 2': -0.6389706106,
  'Unnamed: 3': None,
  'Unnamed: 4': 0,
  'Unnamed: 5': 20,
  'Unnamed: 6': 0},
 {'Financial Ratios': 'Tangible Net Worth Growth',
  'Unnamed: 1': 'Annual Net Worth Growth',
  'Unnamed: 2': 0.0647643295,
  'Unnamed: 3': None,
  'Unnamed: 4': 1,
  'Unnamed: 5': 20,
  'Unnamed: 6': 20},
 {'Financial Ratios': 'Cash and cash equivalents Growth',
  'Unnamed: 1': 'Annual Cash and cash equivalents Growth',
  'Unnamed: 2': -0.503449854,
  'Unnamed: 3': None,
  'Unnamed: 4': 0,
  'Unnamed: 5': 20,
  'Unnamed: 6': 0},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None},
 {'Financial Ratios': None,
  'Unnamed: 1': None,
  'Unnamed: 2': None,
  'Unnamed: 3': None,
  'Unnamed: 4': 'Growth Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 60},
 {'Financial Ratios': 'General Financial Score',
  'Unnamed: 1': 3,
  'Unnamed: 2': 16.8,
  'Unnamed: 3': 5.0,
  'Unnamed: 4': 'General Financial Score',
  'Unnamed: 5': '100/',
  'Unnamed: 6': 36.8},
 {'Financial Ratios': None,
  'Unnamed: 1': 3,
  'Unnamed: 2': 9,
  'Unnamed: 3': None,
  'Unnamed: 4': None,
  'Unnamed: 5': None,
  'Unnamed: 6': None}]

You can use this snippet of code :-

data = json.loads(<stringify_json>)

index_key_mapping = {index: key for index, key in enumerate(data.keys())}
formated_data = [{
    index_key_mapping[index]: value for index, value in enumerate(ord_pair)
} for ord_pair in zip(*[
    dictionary.values() for key, dictionary in data.items()
])]
2 of 3
1

You can use list and .items():

arr_fr = list(json_fr.items())

print('Child title: ', arr_fr[0][0])
print('Child value: ', arr_fr[0][1])
print('Child of child: ', arr_fr[0][1]['3'])

And I get result:

Find elsewhere
🌐
ReqBin
reqbin.com › json › python › uzykkick › json-array-example
Python | What is JSON Array?
Unlike dictionaries, where you can get the value by its key, in a JSON array, the array elements can only be accessed by their index. The following is an example of a JSON array with numbers. Below, you can find a list of JSON arrays with different data types. The Python code was automatically generated for the JSON Array example.
🌐
GeeksforGeeks
geeksforgeeks.org › loop-through-a-json-array-in-python
Loop through a JSON array in Python - GeeksforGeeks
March 28, 2024 - In this example, we will define the JSON data as a string and load it using the and the load() function to convert the JSON data to a Python object. Then using a for loop we will iterate through the array.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-json-to-list
Python Json To List - GeeksforGeeks
April 18, 2026 - JSON (JavaScript Object Notation) is a lightweight data-interchange format widely used in web development and data exchange. In Python, converting JSON to a list is a common task.
🌐
W3Schools
w3schools.com › python › gloss_python_convert_into_JSON.asp
Python Convert From Python to JSON
If you have a Python object, you can convert it into a JSON string by using the json.dumps() method.
🌐
Finxter
blog.finxter.com › 5-best-ways-to-read-json-into-a-numpy-array-in-python
5 Best Ways to Read JSON into a NumPy Array in Python – Be on the Right Side of Change
This method involves parsing the JSON file using the standard library json to convert it to a Python list, and then converting this list into a NumPy array using the function numpy.array().
Top answer
1 of 2
47

In your for loop statement, Each item in json_array is a dictionary and the dictionary does not have a key store_details. So I modified the program a little bit

import json

input_file = open ('stores-small.json')
json_array = json.load(input_file)
store_list = []

for item in json_array:
    store_details = {"name":None, "city":None}
    store_details['name'] = item['name']
    store_details['city'] = item['city']
    store_list.append(store_details)

print(store_list)
2 of 2
1

If you arrived at this question simply looking for a way to read a json file into memory, then use the built-in json module.

with open(file_path, 'r') as f:
    data = json.load(f)

If you have a json string in memory that needs to be parsed, use json.loads() instead:

data = json.loads(my_json_string)

Either way, now data is converted into a Python data structure (list/dictionary) that may be (deeply) nested and you'll need Python methods to manipulate it.


If you arrived here looking for ways to get values under several keys as in the OP, then the question is about looping over a Python data structure. For a not-so-deeply-nested data structure, the most readable (and possibly the fastest) way is a list / dict comprehension. For example, for the requirement in the OP, a list comprehension does the job.

store_list = [{'name': item['name'], 'city': item['city']} for item in json_array]
# [{'name': 'Mall of America', 'city': 'Bloomington'}, {'name': 'Tempe Marketplace', 'city': 'Tempe'}]

Other types of common data manipulation:

  1. For a nested list where each sub-list is a list of items in the json_array.

    store_list = [[item['name'], item['city']] for item in json_array]
    # [['Mall of America', 'Bloomington'], ['Tempe Marketplace', 'Tempe']]
    
  2. For a dictionary of lists where each key-value pair is a category-values in the json_array.

    store_data = {'name': [], 'city': []}
    for item in json_array:
        store_data['name'].append(item['name'])
        store_data['city'].append(item['city'])
    # {'name': ['Mall of America', 'Tempe Marketplace'], 'city': ['Bloomington', 'Tempe']}
    
  3. For a "transposed" nested list where each sub-list is a "category" in json_array.

    store_list = list(store_data.values())
    # [['Mall of America', 'Tempe Marketplace'], ['Bloomington', 'Tempe']]
    
🌐
Towards Data Science
towardsdatascience.com › home › latest › how to perform json conversion, serialization, and comparison in python
How to Perform JSON Conversion, Serialization, and Comparison in Python | Towards Data Science
March 5, 2025 - In Python, the json library can be used for this type of conversion. We use the loads function to convert a JSON string into an object or an array, and use the dumps function to perform the opposite conversion.
🌐
Quora
quora.com › How-will-you-pass-values-to-the-JSON-array-using-Python
How will you pass values to the JSON array using Python? - Quora
Answer (1 of 4): Your question is so wrong on so many things. I won’t really tell you to read the manual. You don’t do this in one pass you see. JSON stands for JavaScript Object Notation, which means, it is Javascript, it is not Python, C or anything else.
🌐
Stack Overflow
stackoverflow.com › questions › 39373836 › python-json-to-array
Python Json to array - Stack Overflow
September 7, 2016 - Do I have to initialize a 3d array? Later it would be fine if I can work on the result like that: ... no - you have to use a list instead: it would work with data=[0,0] instead but see my answer for better solutions ... import json import urllib2 urls=["http://example.com/json","https://example.com/json2"] # your urls here data=[] for u in urls: response = urllib2.urlopen(u) data.append(json.loads(response.read())) # while this normally works with Python 2, it is better to use data.append(json.loads(response.read().decode("utf8"))
🌐
Python
docs.python.org › 3 › library › json.html
JSON encoder and decoder — Python 3.14.8 documentation
The old version of JSON specified by the obsolete RFC 4627 required that the top-level value of a JSON text must be either a JSON object or array (Python dict or list), and could not be a JSON null, boolean, number, or string value.
🌐
Python Examples
pythonexamples.org › python-json-to-list
Python JSON to List
We have to import json package to use json.dumps() function. Note: Please note that dumps() function returns a Python List, only if the JSON string is a JSON Array.