@@ -10,9 +10,9 @@ Data Serialization
10
10
What is data serialization?
11
11
***************************
12
12
13
- Data serialization is theconcept of converting structured data into a format
13
+ Data serialization is theprocess of converting structured data into a format
14
14
that allows it to be shared or stored in such a way that its original
15
- structurecan be recovered or reconstructed. In some cases, the secondary intention of data
15
+ structureshould be recovered or reconstructed. In some cases, the secondary intention of data
16
16
serialization is to minimize the size of the serialized data which then
17
17
minimizes disk space or bandwidth requirements.
18
18
@@ -21,7 +21,7 @@ Flat vs. Nested data
21
21
********************
22
22
23
23
Before beginning to serialize data, it is important to identify or decide how the
24
- data shouldto be structured during data serialization - flat or nested.
24
+ data should be structured during data serialization - flat or nested.
25
25
The differences in the two styles are shown in the below examples.
26
26
27
27
Flat style:
@@ -65,7 +65,7 @@ The repr method in Python takes a single object parameter and returns a printabl
65
65
a= {" Type" :" A" ," field1" :" value1" ," field2" :" value2" ," field3" :" value3" }
66
66
67
67
# the same input can also be read from a file
68
- a=
68
+ a= open ( ' /tmp/file.py ' , ' r ' )
69
69
70
70
# returns a printable representation of the input;
71
71
# the output can be written to a file as well
@@ -135,7 +135,7 @@ structures in Python. One such example is below.
135
135
print (ymlexcp)
136
136
137
137
Documentation on the third party module can be found
138
- `here <https://pyyaml.org/wiki/PyYAMLDocumentation >`__.
138
+ `in the PyYAML Documentation <https://pyyaml.org/wiki/PyYAMLDocumentation >`__.
139
139
140
140
=======================
141
141
JSON file (nested data)
@@ -157,7 +157,7 @@ Writing:
157
157
158
158
..code-block ::python
159
159
160
- # writing JSON content to a file using the dump method
160
+ # Writing JSON content to a file using the dump method
161
161
import json
162
162
with open (' /tmp/file.json' ,' w' )as f:
163
163
json.dump(data, f,sort_keys = True )