Computer science fundamentals · Lesson 46 of 60 · Concept lesson · Optional
Data serialization
Serialization turns data in memory into text or bytes that can be stored or sent, and deserialization turns it back.
JSON and XML are text formats that people can read, while binary formats are smaller and faster but not readable.
Both sides must agree on the format, or the data cannot be understood.
Picture it
Code example
const text = JSON.stringify({ name: "Ada", age: 12 });
console.log(text);
console.log(JSON.parse(text).age);Output:
{"name":"Ada","age":12}
12JSON.stringify serializes, and JSON.parse deserializes.
import json
text = json.dumps({"name": "Ada", "age": 12})
print(text)
print(json.loads(text)["age"])Output:
{"name": "Ada", "age": 12}
12json.dumps serializes, and json.loads deserializes. Python adds spaces after the colons and commas.
Check yourself
Pick an answer for each question. You can retry as many times as you like.
Loading the questions…