CSV vs XML vs JSON – Which is the best response format?

Whether building a thin client (web application) or thick client (client server application) at some point is likely to make requests to a webserver and need a good data format for responses. Three major data formats have now been used to transfer data from a Web server to a client: CSV, XML, and JSON. To develop a solid architecture application, it's a good idea to understand the differences between each format and know when to use them. The purpose of the post is to determine the individual data formats, determine the benefits and disadvantages for each and to find out which situations best work in each format.

CSV

CSV stands for "comma-separated values". As the name suggests, this data format is basically a comma-separated list of elements. Let's say your answer will return the list of people in your family. The format will look like this:

Eric, Andrea, Kusco

Benefits – This format is the most complex of all three formats. Generally speaking, CSV formats are about half of XML and JSON formats. This is the most important advantage of CSV because it can reduce bandwidth

Disadvantages – This format is the least versatile in all three formats. This is because a home analyst is required to convert CSV data into a native data structure. As a result, if the data structure changes, there is an associated additional cost to change or even redirect your commands. In addition, since CSV and CSV analytics program is found on different machines (remember to transfer data from one machine to another), both programs must be updated at one time to prevent the host program from crashing. Otherwise, the lead time is required to update each program individually to avoid conflicts of interest.

Finally, CSV does not support the hierarchy of data. What would be the attributes you want to send to each individual in every family? You will then need to compile a composite analyst to know which parts of the CSV refer to a family element, and which parts refer to the element of each element. One way to resolve this issue is to use another delimiter, such as ";" separating the attribute of each person:

XML,

XML, "can be expanded to include the individual attribute of a person:

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

marking language ". XML was designed in 1996 and officially created in 1998 as a W3C standard. This was designed to better represent hierarchically structured data formats. 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>

Benefits – This data format fully supports hierarchical data structures and is very appropriate when receiving complex data in response. It is very human. Most browsers contain built-in XML readers that allow you to check XML files. Because XML was the first standard hierarchical data format, most APIs have built-in functionality to automatically convert XML data streams to native data structures, such as objects

Disadvantages – This data format is three times the CSV. This is because there is an open and close parameter tag associated with each data item.

JSON

JSON Report (Javascript Object Notation). It was invented in 2001 and was popularized in 2005 and 2006 by Yahoo and Google. It was created as an alternative to XML. Like XML, it also displays hierarchical data with comma, curved handles and brackets. The example of JSON looks like this:

{"name": "Eric", "age": "26"},

{"name": "Andrea", "age": "26"},

{"Name": "Kusco", "Age": "8"}

Benefits – This data format supports hierarchical data while being smaller than XML. As its name suggests, it was also created to better interpret data for native Javascript objects, making it very useful for web applications. JSON is the best of both worlds for CSV and XML. It's simple and compact like CSV, but it supports hierarchical data such as XML. Unlike XML, JSON formats are only about twice as large as CSV formats.

Disadvantages – This data format is less supportive of XML. Because JSON is relatively new to XML, there are fewer APIs that JSON automatically transforms into native data structures. However, this changes rapidly as new APIs and extensions support both XML and JSON.

Conclusion

As a general rule, JSON is the best data exchange format so far. Lightweight, compact and versatile. CSV can only be used if you send huge amounts of data and if bandwidth is in question. Today, XML should not be used as a data exchange format because it is more suited to document markup.

Source by visit sbobet thailand

Leave a Reply

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