CSV versus XML versus JSON

How should I send data? Well, it depends.

CSV: Use this whenever possible, any non-programmer will be able to use it. Works well for tabular data, if you included the heading as the first row, if the heading is in business terms. Easy to parse unless invalid or poorly escaped characters exist in your data. Difficult to validate. Does not work well for tabular or hierarchical data.

XML: Most programs can generate or consume xml. Some programmer skills are required of the user. The data requires a DTD or schema in order for the programmer/user to validate it. Easy to read, difficult to parse. Works well with any structured data, most unstructured data.

JSON: Can be parsed without a schema if the user has programmer skills. Find a library instead of using eval when validating or risk the vulnerability of hackers penetrating your program or system. Easier to do mashups because datasets can be modified, conformed, or extended. Good fit for structured or unstructured data.

Leave a Reply

Your email address will not be published. Required fields are marked *