#105 parse JSON and YAML

25/01/2023
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

0
Sign in to join the conversation