Data in transmitted accross platforms using API calls. Data is mostly retrived in JSON format. We can convert the obtained JSON data into String data for the ease of storing and working with it.
Let’s see how to convert JSON to String.
Method #1: Json to String on dummy data using “json.dumps”
import json # create a sample json a = {"name" : "GeeksforGeeks", "Topic" : "Json to String", "Method": 1} # Convert JSON to String y = json.dumps(a) print(y) print(type(y)) |
chevron_right
filter_none
Output:
Method #2: Json to String using an API using requests and “json.dumps”
import json import requests # Get dummy data using an API # Convert data to dict data = json.loads(res.text) # Convert dict to string data = json.dumps(data) print(data) print(type(data)) |
chevron_right
filter_none
Output:
Recommended Posts:
- Python - Difference between json.dump() and json.dumps()
- JSON | modify an array value of a JSON object
- Python | Ways to convert string to json object
- Convert Java Object to Json String using Jackson API
- Convert Java Object to Json String using GSON
- Convert Json String to Java Object Using GSON
- How to Convert JS Object to JSON String in JQuery/Javascript?
- Convert JSON to dictionary in Python
- Convert JSON to CSV in Python
- Convert Text file to JSON in Python
- How To Convert Python Dictionary To JSON?
- How to convert pandas DataFrame into JSON in Python?
- Convert CSV to JSON using Python
- Convert JSON data Into a Custom Python Object
- JavaScript | Convert an array to JSON
- How to convert PHP array to JavaScript or JSON ?
- How to convert JSON data to a html table using JavaScript/jQuery ?
- How to convert JSON results into a date using JavaScript ?
- Convert PyMongo Cursor to JSON
- How to Convert CSV to JSON file having Comma Separated values in Node.js ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



