0Pricing
Ruby Academy · Lesson

Choosing a Format

Trade-offs.

Three Formats, Three Jobs

You now know JSON, CSV, and YAML. Each shines in different situations. Picking the right one keeps your data easy to produce, store, and consume.

  • JSON for APIs and web
  • CSV for tabular/spreadsheet data
  • YAML for configuration
puts ['JSON', 'CSV', 'YAML'].join(', ')

JSON Strengths

JSON is compact, universally supported, and maps to nested Hashes and Arrays. It is the de facto standard for web APIs and data interchange between services.

require 'json'
puts({ id: 1, items: [1, 2] }.to_json)

All lessons in this course

  1. Reading and Writing JSON
  2. Working with CSV
  3. YAML Configuration
  4. Choosing a Format
← Back to Ruby Academy