
- 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 pass a json object as a parameter to a python function?
We have this code below which will the given json object as a parameter to a python function.
example
import json json_string = '{"name":"Rupert", "age": 25, "desig":"developer"}' print type (json_string) def func(strng): a =json.loads(strng) print type(a) for k,v in a.iteritems(): print k,v print dict(a) func(json_string)
Output
<type 'str'> <type 'dict'> desig developer age 25 name Rupert {u'desig': u'developer', u'age': 25, u'name': u'Rupert'}
- Related Articles
- How to pass an object as a parameter in JavaScript function?
- How to pass a function as a parameter in Java
- How to pass Python function as a function argument?
- How to pass a 2D array as a parameter in C?
- How to return a json object from a Python function?
- How to pass a jQuery event as a parameter in a method?
- How to pass a lambda expression as a method parameter in Java?
- How to pass a dictionary as argument in Python function?
- How to pass an array as a URL parameter in Laravel?
- How to return a JSON object from a Python function in Tkinter?
- How can I pass a parameter to a setTimeout() callback?
- C# Program to pass Parameter to a Thread
- How can we pass an empty string as a parameter to BIT_LENGTH() function and what would be returned by MySQL?
- How to set default parameter values to a function in Python?
- How to pass optional parameters to a function in Python?

Advertisements