-
Notifications
You must be signed in to change notification settings - Fork 0
/
01serilisers.txt
68 lines (25 loc) · 1011 Bytes
/
01serilisers.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
python json
dumps(data)
-used to convert python object into json string.
eg:-
import json
python_data={'name':'cicero','roll':45}
json_data=json.dumps(python_data)
loads(json_data)
-used to convert json to python objects
parse_data=json.loads(json_data)
serializers
- helps to convert complex datatype like python_datatypes into
json,xml or other content types which is understandable by frontend.
- serializers are also responsible for deserialization which helps to
convert parse_data back into complex data after validating
the incomming data.
complex data ------> python native datatype -------> json_data
serialization render in into json
jsonRenderer
-used to render serilised data into json
-import jsonRenderer
-from restframework.renders
render data into json
json_data = JSONRenderer().render(serizer.data)
code in project1