- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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'}
Advertisements