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
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
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.
๐ŸŒ
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"))
๐ŸŒ
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.
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ read-numeric-data-from-a-json-file-into-a-numpy-array.php
Read numeric data from a JSON file into a NumPy array
September 1, 2025 - Import NumPy and JSON Libraries: Import the NumPy and JSON libraries to handle arrays and JSON data. Define JSON File Path: Specify the path to the JSON file containing the numeric data.
๐ŸŒ
TestMu AI Community
community.testmuai.com โ€บ ask a question
How can I convert a JSON array to a Python list? - Ask a Question - TestMu AI (formerly LambdaTest) Community
January 9, 2025 - I have the following JSON array: import json array = '{"fruits": ["apple", "banana", "orange"]}' data = json.loads(array) In this case, I want to convert all the values in the โ€˜fruitsโ€™ string to a Python list. What isโ€ฆ