Wrapping Up

The world of serialization is dominated by three main formats, each with their strengths and weaknesses, and we’ve looked at all three of them here. The first was JSON, which is common on the web and will allow us to communicate with many different APIs—as well as being the easiest of the formats to edit by hand.

Then we looked at XML, which is still found in many places despite perhaps declining from its mid-2000s heyday. We used the DSL specified by the Builder library to build up our XML element by element in a readable way.

Finally, we looked at the CSV file. CSVs are common in data that’s destined for databases, spreadsheets, and the import routines of many online services, so being able to write data into this format will allow us to write files that can be consumed by these services.

Sometimes, though, we need to write data into much more complex or ad hoc formats. In these cases we can define templates that specify exactly how our output will be structured. The next chapter explores how we can do this in Ruby.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.76.154