
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to return a json object from a Python function?
We return a json object from a python function as follows using given python dictionary.
Example
import json a = {'name':'Sarah', 'age': 24, 'isEmployed': True } # a python dictionary def retjson(): python2json = json.dumps(a) print python2json retjson()
Output
{"age": 24, "isEmployed": true, "name": "Sarah"}
- Related Articles
- How to return a JSON object from a Python function in Tkinter?
- How to return an object from a function in Python?
- How to return an object from a JavaScript function?
- How to pass a json object as a parameter to a python function?
- How to return a matplotlib.figure.Figure object from Pandas plot function?
- How to construct a JSON object from a subset of another JSON object in Java?
- How can we return a dictionary from a Python function?
- How to return void from Python function?
- How to convert JSON data into a Python object?
- How can a Python function return a function?
- How to return a value from a JavaScript function?
- How to return a string from a JavaScript function?
- How to get the return value from a function in a class in Python?
- How I can create Python class from JSON object?
- How to de-serialize a Polyline object from JSON in FabricJS?

Advertisements