Challenge 3: YAML vs JSON on the Same Data — Solution require "json" require "yaml" profile = { name: "Philip", email: "philip@example.com", tags: ["ruby", "php", "python"] } yaml_string = profile.to_yaml json_string = profile.to_json puts "--- YAML ---" puts yaml_string puts "--- JSON ---" puts json_string yaml_loaded = YAML.load(yaml_string) json_loaded = JSON.parse(json_string) puts "YAML key class: #{yaml_loaded.keys.first.class}" puts "JSON key class: #{json_loaded.keys.first.class}" =begin Output: --- YAML --- --- :name: Philip :email: philip@example.com :tags: - ruby - php - python --- JSON --- {"name":"Philip","email":"philip@example.com","tags":["ruby","php","python"]} YAML key class: Symbol JSON key class: String Notes: - YAML's own output syntax literally shows the leading colon (:name, :email, :tags) because YAML has a real representation for Ruby symbols, and YAML.load faithfully reconstructs them as symbols afterward. - JSON's output has no equivalent marker for symbols at all ("name" looks identical to how a string key would look), and JSON.parse (called here with no symbolize_names option) returns plain String keys as a result. - This is the comparison table's "preserves symbols/custom classes?" row made concrete: YAML says yes, JSON says no, and the printed key classes confirm it directly. =end