Junior — Middle
What technologies or approaches have you used to convert data into a format suitable for storage or transmission, and to restore it from that format?
sobes.tech AI
Answer from AI
The following technologies and approaches are often used for converting data into a format suitable for storage or transmission, and subsequent recovery:
-
Serialization/deserialization: Converting objects to a byte sequence and back.
-
Data formats: JSON, XML, YAML — convenient for text representation and network transmission.
-
Binary formats: Protocol Buffers, Avro, MessagePack — more compact and efficient.
-
Standard Python libraries:
jsonfor JSON,picklefor binary serialization of Python objects.
Example of JSON serialization and deserialization in Python:
import json
data = {'name': 'Alice', 'age': 30}
# Serialization
json_str = json.dumps(data)
# Transmission or storage
# Deserialization
restored_data = json.loads(json_str)
The choice of approach depends on performance requirements, readability, and compatibility.