Heads up: This description was created by AI and might not be 100% accurate.

deserialization.rb

This Ruby code snippet demonstrates deserialization of a serialized Ruby object. It reads a serialized string from the ‘person.dat’ file, which represents a Ruby hash containing a person’s name and age. The Marshal.load function then parses this serialized string back into a Ruby hash, resulting in the hash {name: "Alice", age: 30}.

Ruby code snippet

serialized_person = File.read('input/serialization/person.dat')
#=> "\u0004\b{\a:\tnameI\"\nAlice\u0006:\u0006ET:\bagei#"
Marshal.load(serialized_person)
#=> {name: "Alice", age: 30}

Executed with Ruby 3.4.5.