Append to JSON file using Python Last Updated : 26 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The full form of JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Python script. The text in JSON is done through quoted-string which contains the value in key-value mapping within { }. Functions Used: json.loads(): json.loads() function is present in python built-in 'json' module. This function is used to parse the JSON string. Syntax: json.loads(json_string)Parameter: It takes JSON string as the parameter.Return type: It returns the python dictionary object. json.dumps(): json.dumps() function is present in python built-in 'json' module. This function is used to convert Python object into JSON string. Syntax: json.dumps(object)Parameter: It takes Python Object as the parameter.Return type: It returns the JSON string. update(): This method updates the dictionary with elements from another dictionary object or from an iterable key/value pair. Syntax: dict.update([other])Parameters: Takes another dictionary or an iterable key/value pair.Return type: Returns None. Example 1: Updating a JSON string. Python3 # Python program to update # JSON import json # JSON data: x = '{ "organization":"GeeksForGeeks","city":"Noida","country":"India"}' # python object to be appended y = {"pin":110096} # parsing JSON string: z = json.loads(x) # appending the data z.update(y) # the result is a JSON string: print(json.dumps(z)) Output: {"organization": "GeeksForGeeks", "city": "Noida", "country": "India", "pin": 110096} Example 2: Updating a JSON file. Suppose the JSON file looks like this. We want to add another JSON data after emp_details. Below is the implementation. Python3 # Python program to update # JSON import json # function to add to JSON def write_json(new_data, filename='data.json'): with open(filename,'r+') as file: # First we load existing data into a dict. file_data = json.load(file) # Join new_data with file_data inside emp_details file_data["emp_details"].append(new_data) # Sets file's current position at offset. file.seek(0) # convert back to json. json.dump(file_data, file, indent = 4) # python object to be appended y = {"emp_name":"Nikhil", "email": "[email protected]", "job_profile": "Full Time" } write_json(y) Output: Comment More infoAdvertise with us Next Article Append to JSON file using Python aman neekhara Follow Improve Article Tags : Python Python-json Practice Tags : python Similar Reads Read JSON file using Python The full form of JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Pytho 4 min read Reading and Writing JSON to a File in Python The full form of JSON is Javascript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Pytho 3 min read How to Upload JSON File to Amazon DynamoDB using Python? Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. It offers scalability, reliability, and fast access to data for applications of any scale. DynamoDB supports both document and key-value data models and handles adminis 3 min read GET and POST Requests Using Python This post discusses two HTTP (Hypertext Transfer Protocol) request methods  GET and POST requests in Python and their implementation in Python. What is HTTP? HTTP is a set of protocols designed to enable communication between clients and servers. It works as a request-response protocol between a cli 7 min read Python - Dict of tuples to JSON In this article, we will discuss how to convert a dictionary of tuples to JSON. Method 1: Using json.dumps() This will convert dictionary of tuples to json Syntax: json.dumps(dictionary, indent) Parameters:  dictionary is the input dictionary.indent specify the number of units of indentation Exampl 2 min read Working With JSON Data in Python JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Python script. The tex 6 min read Fetch JSON URL Data and Store in Excel using Python In this article, we will learn how to fetch the JSON data from a URL using Python, parse it, and store it in an Excel file. We will use the Requests library to fetch the JSON data and Pandas to handle the data manipulation and export it to Excel.Fetch JSON data from URL and store it in an Excel file 3 min read Convert Text file to JSON in Python JSON (JavaScript Object Notation) is a data-interchange format that is human-readable text and is used to transmit data, especially between web applications and servers. The JSON files will be like nested dictionaries in Python. To convert a text file into JSON, there is a json module in Python. Thi 4 min read Read, Write and Parse JSON using Python JSON is a lightweight data format for data interchange that can be easily read and written by humans, and easily parsed and generated by machines. It is a complete language-independent text format. To work with JSON data, Python has a built-in package called JSON. Example of JSON String s = '{"id":0 4 min read How to JSON decode in Python? When working with JSON data in Python, we often need to convert it into native Python objects. This process is known as decoding or deserializing. The json module in Python provides several functions to work with JSON data, and one of the essential tools is the json.JSONDecoder() method. This method 5 min read Like