Call us on : 02070336860

The Apple Repair Station- The Mac Parts and Apple Repairs Specialist, Business, Education and Home User Support, London | UK

  • Home
  • Repairs
    • ARS Liquid Damaged Revival
    • Apple Mac Repair
    • iPad
    • iPhone
    • Insurance Quotation
  • Solutions
    • Data Shredding
    • Mac Support
    • Trade in
    • Upgrade SSD / RAM
    • WiFi Solutions
  • Data Recovery
    • iDevices
    • Internal/External HDD
  • Store
  • Repair Status
    • Check Your Repair Status – Kingsland Store
    • Check Your Repair Status – Angel Store
  • Contact
  • MY CART
    No products in cart.
 March 23, 2023

CSV vs XML vs JSON – Which is the Best Response Data Format?

by admin / Friday, 10 March 2017 / Published in Uncategorised

Whether you are building a thin client (web application) or thick client (client-server application) at some point you are probably making requests to a web server and need a good data format for responses. As of today, there are three major data formats being used to transmit data from a web server to a client: CSV, XML, and JSON. In order to develop an application with a solid architecture, it’s a good idea to understand the differences between each format and know when to use them. The purpose of this post is to define each data format, lay out the pros and cons for each, and discover which situations work best with each format.

CSV

CSV stands for “comma separated values”. As the name implies, this data format is basically a list of elements separated by commas. Let’s say that your response is sending back a list of people in a particular family. The format would look like this:

Eric,Andrea,Kusco

Pros – This format is the most compact of all three formats. Generally speaking, CSV formats are about half the size of XML and JSON formats. This is the major advantage of CSV because it can help reduce bandwidth

Cons – This format is the least versatile of all three formats. This is because a homemade parser is required to convert the CSV data into a native data structure. As a result, if the data structure changes, there is an associated overhead of having to change or even redesign your parsers. Furthermore, since the program creating the CSV and the program parsing the CSV reside on different machines (remember that we are passing data from one machine to another) then both programs must be updated simultaneously to prevent the receiving program to crash. Otherwise, an outage is required to update both programs individually to prevent incompatibility issues.

Finally, CSV does not really support data hierarchies. What if you wanted to send back attributes for each person in each family? You would then have to design a complex parser that knows which parts of the CSV are referring to elements of a family, and which parts are referring to elements of each person. One way to solve this problem is to use another delimiter like “;” to separate each person’s attribute:

Eric;male;26,Andrea;female;26,Kusco;male;8

The problem with creating customized formats, however, is that you incur an overhead of maintaining an even more complex parser.

XML

XML stands for “extensible markup language”. XML was designed in 1996 and officially became a W3C standard in 1998. It was created to better represent data formats with a hierarchical structure. The format looks like this:

<person> <name><br /> Eric<br /> </name><br /> <age><br /> 26<br /> </age> </person> <person> <name><br /> Andrea<br /> </name><br /> <age><br /> 26<br /> </age> </person> <person> <name><br /> Kusco<br /> </name><br /> <age><br /> 8<br /> </age> </person>

Pros – This data format fully supports hierarchical data structures and is very appropriate when receiving complex data as a response. It is also very human readable. Most browsers have built in XML readers that allow you to inspect XML files. Since XML was the first standard hierarchical data format, most APIs have built in functionality to automatically convert XML data streams into native data structures like objects.

Cons – This data format is about three times as large as CSV. This is because each data element has an associated open and close parameter tag.

JSON

JSON stands for (Javascript Object Notation). It was invented in 2001 and became popularized by Yahoo and Google in 2005 and 2006. It was created as an alternative to XML. Like XML, however, it represents hierarchical data with the use of commas, curly braces and brackets. An example of JSON looks like this:

{“name”:”Eric”,”age”:”26″},

{“name”:”Andrea”,”age”:”26″},

{“name”:”Kusco”,”age”:”8″}

Pros – This data format supports hierarchical data while being smaller in size than XML. As its name implies, it was also created to more easily parse data into native Javascript objects, making it very useful for web applications. JSON is the best of both worlds with respect to CSV and XML. It’s simple and compact like CSV, but supports hierarchical data like XML. Unlike XML, JSON formats are only about twice as large as CSV formats.

Cons – This data format has a little bit less support than XML. Since JSON is relatively newer than XML, fewer APIs exist to automatically convert JSON to native data structures. However, this is rapidly changing because newer APIs and plugins are supporting both XML and JSON.

Conclusion

As a general rule of thumb, JSON is the best data exchange format to date. It’s light weight, compact, and versatile. CSV should only be used if you are sending huge amounts of data and if bandwidth is an issue. Today, XML should not be used as a data exchange format because it’s better suited for document markups.


Source by Eric D Rowell

0
  • Tweet

About admin

What you can read next

ThinkPad Laptops – Advantages, Features and Accessories
How Gurgaon's Real Estate Can Gain From Their Budget in 2017
How to Subtly Tease a Guy? 7 Fabulous Tips That Will Get Your Message Across Really Quickly

Recent Posts

  • Mobile App Development Trends to Look Out For

    In the recent years, the mobile app industry ha...
  • The Advancement of Hotel Revenue Management

    Hotels across the globe consistently tweak thei...
  • 5 Ways to Build Enterprise Mobile Apps "The Right Way"

    “78% enterprise apps are abandoned after ...
  • iOS Localization: Fixing the Last-Mile Problem

    It's the era of the apps. Every stream of l...
  • How Can Mobile Payments Ramp Up Your Sales And ROI?

    The Smart phones, the eCommerce, the M-commerce...

Recent Comments

    Archives

    • December 2019
    • November 2019
    • October 2019
    • September 2019
    • August 2019
    • July 2019
    • June 2019
    • May 2019
    • April 2019
    • March 2019
    • February 2019
    • January 2019
    • December 2018
    • November 2018
    • October 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • April 2018
    • March 2018
    • February 2018
    • January 2018
    • December 2017
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • July 2017
    • June 2017
    • May 2017
    • April 2017
    • March 2017
    • February 2017
    • January 2017
    • December 2016

    Categories

    • Uncategorised

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Featured Posts

    • Mobile App Development Trends to Look Out For

      0 comments
    • The Advancement of Hotel Revenue Management

      0 comments
    • 5 Ways to Build Enterprise Mobile Apps "The Right Way"

      0 comments
    • iOS Localization: Fixing the Last-Mile Problem

      0 comments
    • How Can Mobile Payments Ramp Up Your Sales And ROI?

      0 comments

    SEARCH

    RECENT POSTS

    • Mobile App Development Trends to Look Out For

    • The Advancement of Hotel Revenue Management

    • 5 Ways to Build Enterprise Mobile Apps "The Right Way"

    TAG CLOUD

    Get a quote

    To get an immediate quotation
    Please contact us NOW!

    Careers

    Send your CV
    to jobs@shoreditchmacrepair.com

    Shop Refurbished Macs

    Check our latest refurbished Macs here.

    Copyright © 2022 Apple Repair Station. Support by MaSha Design.

    Tech Desk  | Blog | Contact Us

    united_kingdom_640United Kingdom

    TOP