w2d1 Flashcards
1
Q
What does “serialization” refer to?
A
The conversion of an object into a representation that can be stored on a disk or sent over a network.
2
Q
What is the most common form of serialization on the web?
A
JSON
3
Q
How can a Ruby object be serialized into JSON?
A
Include the ‘json’ gem, then use JSON::parse on the basic class (hash, array, etc.)
4
Q
What is the best way to serialize a custom Ruby class or complex object?
A
Use YAML
5
Q
How do we use YAML to serialize?
A
Require the ‘yaml’ gem, the use Object#to_yaml
6
Q
How do we use YAML to deserialize?
A
Require the ‘yaml’ gem, then use YAML::load(yaml_string)