Introduction of Python
Getting Started with Python
Syntax in Python
Comment in Python
Variables in Python
Data Types in Python
Numbers in Python
Castings in Python
Strings in Python
Boolean in Python
Operators in Python
List in Python
Tuples in Python
Sets in Python
Dictionary in Python
if Else Statement in Python
While Loop in Python
For Loop in Python
Functions in Python
Lamba Function in Python
Arrays in Python
Classes and Objects in Python
Inheritance in Python
Iterators in Python
Scope in Python
Modules in Python
Dates in Python
Math in Python
JSON in Python
RegEx in Python
Try and Except in Python
User Input in Python
String Formatting in Python
Python JSON Overview
JSON means JavaScript Object Notation. JSON ki help se data ko ek end se dusre end tak pahuchaya jata hai. Isko simple example se samjhte hain – Suppose kariye apne pass do system hai, jaha first system me python programming use ho rahi hai aur wahi dusre system me C Programming.
Systems me proper communication hone ke liye data ka exchange hona jaruri hai. Ab yaha JSON ek bahut hi important role play karega, kyuki JSON ke syntax ko read karne ki capability har ek programming language ke pass hoti hai issliye JSON ki wajah se ye dono system aapas me proper communication banaye rakhenge.
Python me JSON ek built-in package hai, jise hum directly import kar sakte hain.
json.dumps() function in Python
Python object ko JSON string me convert karne ke dauran json.dumps() function ka use kiya jata hai. Dusre shabdo me bole to Python se JSON parsing ke dauran json.dumps() function ka use kiya jata hai. Example se samajhte hain:
#PYTHON TO JSON
import json
# ‘student’ – Python Object hai
student = {
“name”: “saurav”,
“age”: 28,
“city”: “Indore”
}
# python object ka JSON me conversion:
candidate = json.dumps(student)
print(candidate)
json.loads() function in Python
json.loads() function ki functionality json.dumps() function ke opposite hai. Yaha JSON ko python me me convert kiya jata hai. Dusre shabdo me bole to JSON se Python parsing ke dauran json.loads() function ka use kiya jata hai. Example se samajhte hain:
#JSON TO Python
import json
# ‘student’ – JSON hai
student = ‘{ “name”: “saurav”, “age”: 28, “city”: “Indore” }’
# JSON ka Python object me conversion:
candidate = json.loads(student)
print(candidate)
Python Objects ka JSON se relation
PYTHON
- dict
- list
- tuple
- str
- int
- float
- True
- False
- None
JSON
- Object
- Array
- Array
- String
- Number
- Number
- true
- false
- null