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 ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.