Use classes to represent data

1 · Ryan Bigg · Sept. 18, 2024, midnight
Accessing JSON structures through strings is an anti-pattern and a sign of lazy programming. When we write Ruby code, we use classes to represent data within our own applications. Typically, these are models from within the Rails application. But I’ve seen a repeated pattern of Rubyists consuming JSON data without first casting that to an object. It opens the door for mistakes to be made, especially when it comes to typos in strings. It’s too easy to get muddled up and think things are different...