# #105 parse JSON and YAML

- URL: https://superails.com/posts/ruby-on-rails-105-parse-json-and-yaml
- Published: 2023-01-25
- Duration: 09:12
- Access: free
- Topics: yaml, json, data parsing

JSON and YAML are great ways of storing data structures.
You can parse a JSON/YAML file directly with Ruby, or within a Rails application.
You can also WRITE to the file!

Popular usecases:
- parse file and create seed data
- display parsed default data directly in a view (for example FAQ section)

Episode source code:
https://github.com/corsego/105-parse-yaml-json/commit/90282b5468fbfe78bcbb1df29ef91de5eaa160a2

Parse JSON with Ruby on Rails: https://blog.corsego.com/parse-json-with-ruby-on-rails
Parse YAML with Ruby on Rails: https://blog.corsego.com/parse-yaml-yml-with-ruby-on-rails

0:00 incoming JSON and YAML data
0:50 parse YAML with Ruby (no Rails)
2:01 update and save YAML file
3:01 parse JSON with Ruby (no Rails)
3:50 display YAML in Rails controller
6:05 display JSON in Rails controller
6:37 seed database data from datafile

## Chapters

- 0:00 incoming JSON and YAML data
- 0:50 parse YAML with Ruby (no Rails)
- 2:01 update and save YAML file
- 3:01 parse JSON with Ruby (no Rails)
- 3:50 display YAML in Rails controller
- 6:05 display JSON in Rails controller
- 6:37 seed database data from datafile
