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

July 23, 2018

Recovery Vehicles

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.

24 Comments

  • Tassey Saavedra July 23, 2018 at 10:12 am

    For me,the vegan diet caused me to restrict more .Not on purpose.Maybe one day,I'll try again when I'm better.

  • Yue Qi July 23, 2018 at 10:12 am

    it's so moving to know William's love towards you is such pure, everlasting and selfless.

  • saydiejade July 23, 2018 at 10:12 am

    Aw it makes me smile when you talk about your bf bc I feel the same way about mine and he builds up my confidence and always tells me I’m beautiful! All girls should have a guy like that!

  • Danie van Kay July 23, 2018 at 10:12 am

    I personally am not vegan (have been vegan for 6 months in the past) and it didn’t work for my body. I strongly believe in bio individuality and everyone should do whatever they want. I’m very particular about my meat, poultry and fish sources. I only chose organic or grass fed. I found being vegan another restriction, but like I said; EVERYONE should do what feels right to them. Let’s just all love and support each other either way.❤️ Love this video!

  • p nut July 23, 2018 at 10:12 am

    Hello! Im a recovering bulimic and i want to become vegan because of the health benefits and of course contributing to saving animals. Do u think its a good idea rn or should i wait till im in a better place in recovery? ( im definatly going in the right direction but i still b/p more often than id like to)

  • Sweetie Bear July 23, 2018 at 10:12 am

    Hi to Everyone that has a food problem:
    You need to visit two websites,..
    1) Dr. Susan Peirce Thompson at brightlineeating.com
    2) Dr. Joel Fuhrman at drfuhrman.com
    Here you find a lot of help that you need.
    I highly recommend them as they have helped my food problems.

  • Leo July 23, 2018 at 10:12 am

    I had an ED that was like real quick (one and a half year) but very strong and deep. I went vegan to be able to eat as much as I want, I binged for six months, I gained ALL the weight back and now I plateu at around six kilos more than I was before all that sh*t. I love veganism, it really helps my ED-leftovers, but I‘m kinda stuck in not eating healthy and then feeling guilty. I’d love to lose weight and get healthy but I feel like I don’t know what healthy is any more. Yeah, like WFPB (whole food peanut butter, teehee) is healthy, but I want to eat wraps and bananas and peanut butter (the pure stuff, not the oily-salty-sugary stuff). Sometimes I discover nice meals (potatoes, green beans, white beans and tahini, honestly, it’s the BEST) but they bore me after some time. I don’t have much variety, I hate kale and nice cream and I’m LAZY. I’d eat melon all day, but it’s expensive where I live. I don’t know what to do, has anyone advice? Sorry for the long comment and sorry for bad english.

  • FitPugMom July 23, 2018 at 10:12 am

    This is beautiful.

  • Shunhua Zhu July 23, 2018 at 10:12 am

    i m inspired to pursue recovery again after relapsing for two months qwq. Now a week purge free, but been eating consistently average 3500 kcal a day(no need to gain weight cuz in the high range of healthy BMI-23) I found that I naturally eat a lot less(2000-2500) if I do full whole foods plant based without restriction. So I wonder in your recovery journey, do you always pursue whole-foods diet or a mix? and I am not sure whether I should be whole-foods so that I can find my hunger/fullness cue back faster. (Get kinda bingey on highly palatable foods). Gaining weight is no longer that scary to me, just asking out of: which is better for mental healthy recovery from ED. Thank you so much<3

  • Stephanie To July 23, 2018 at 10:12 am

    what's your suggestion to ppl that doesn't have access to vegan products but is considering to go vegan? I'm from China and vegan snacks/meat do not exist AT ALL. So frustrating! I don't think I'll last if I can only eat veggies and fruits. I'm a busy student and I can't meal prep as well. :((((

  • almut k July 23, 2018 at 10:12 am

    Off topic but your makeup looks amazing in this video 😍 Really good Q&A! I think I also learned a few things, can't wait for more parts

  • Jasmine X July 23, 2018 at 10:12 am

    Add up @lushiousleek insta

  • Lisa Pittman July 23, 2018 at 10:12 am

    New subscriber. Your story is ME TO A POINT!!!! Thank you from the bottom of my heart for informing people about calorie restriction and that being overweight does not mean your body is done its healing and it takes time. It is so comforting to hear your story and know I am not in this alone <3

  • FN Salay July 23, 2018 at 10:12 am

    I love all your videos. You always give such insightful answers/advice. I have an eating disorder- it’s not active right now, but I feel like once you’ve been through it, it’s always something that you need to fight against. Veganism actually HELPS my ED b/c it helps me to be more mindful & healthy. So I completely agree with you there. Anyway, thanks for another insightful video. 💜💜

  • Kara Helland July 23, 2018 at 10:12 am

    Thank you for your videos! I wanted to ask you a bit more about being vegan. What are your views for the people who find their bodies respond better to a standard American diet? Although I completely understand and respect your lifestyle, my body finds veganism to be restrictive, therefore I don’t agree that it is the “healthiest” option for every body. I am not trying to discourage veganism at all, and I have nothing against it, it just doesn’t work for my body. Would you still tell someone who also doesn’t find veganism to be sustainable to do it anyway? Thank you again, I love your videos and appreciate your thoughts 💜

  • Martha Mugnaio July 23, 2018 at 10:12 am

    Is your boyfriend vegan? It's great you found somebody like him. You are such a beautiful human being (on the outside as on the Inside) and you really deserve somebody who appreciate both. Lots of Love <3

  • Joanna Kłosowska July 23, 2018 at 10:12 am

    The next great video!👏 You are extremely inspiring and helpful💖. I am so happy hearing abut your relationship with William. He seems to be very supportive partner. I am very glad you have so valuable boyfriend. You deserve lots of love and happiness💖💖.

  • blueberry queen July 23, 2018 at 10:12 am

    Would you make a video about body checking and how to stop it? I still struggle with it.. thanks for your support❤️

  • Shannon Ray July 23, 2018 at 10:12 am

    Also I'm so happy for you that you've found William 🙂 🙂 It's so refreshing to be with someone you know is with you for who you are. I'm moving to start grad school soon and at my overshoot weight.. I've basically just written off the possibility of meeting anyone or starting to date anyone. I also buzzed my hair during my ED because I was out of my mind and it's grown in the 7 months since then but it's still super short and I've never in my life felt so unattractive, haha. I think if I meet anyone this year I'll know they're not into me for the way I look…

  • Ji Yeon Kwon July 23, 2018 at 10:12 am

    OMG I'm early yay! Alice you are one of my favorite vegan youtubers 🙂 I have a quick question though, what's the difference between cocoa and cacao? You've mentioned that you assume we know the difference, but I would love to hear an explanation from you! As always, love you so much!

  • Shannon Ray July 23, 2018 at 10:12 am

    Yes, absolutely!!!! A WFPB diet is the key to full recovery — boosting your metabolism, healing as best as you possibly can, committing to PERMANENT recovery. I know so many people who are disordered eaters (who have never struggled with EDs, per se) and it seems so many women who do struggle with EDs never fully recovery mentally, are always exercise-purging or under-eating or feeling guilty about eating, etc. Worried about gaining weight for the rest of their lives. This makes me so, so, so, so happy that I went all in from day 1 (granted with bumps in the first couple months) on a whole food, plant-based diet, embracing extreme hunger and eating tons for a couple of months and sticking with eating no matter how hungry I am. I feel like, like you, if I didn't know I was nourishing my body with the best foods and treating myself and my body as kindly as I possibly can then I would not have been able to commit 100% to basically eating bucketloads and trusting in this process completely. Honestly, the number 1 thing that keeps me from questioning myself during my overshoot plateauing phase is knowing that there's nothing more I can possibly do. I'm eating the best foods possible for my mental and physical health, I'm eating the foods I love the most, and I'm moving in a healthy way, and that knowledge and how GOOD I feel doing this means there's no other way for me, I'll never go back to restricting and I'll probably be the least disordered eater I know for the rest of my life. If I'm giving my body all I can, I never have to question anything it does or how much it wants to weigh.

  • Jen Nesset July 23, 2018 at 10:12 am

    Yes!!! Right around the five minute mark you said that your plant based diet helped you recover faster, helped with bloating, skin issues, a FULL recovery. YES!!! I told my nutritionist that if I’m going to eat, and really recover, that I want to rebuild my body with whole, plant-based foods. The body just processes these natural foods better. I became vegan for health reasons (plant-based really helped me tackle fear of carbs) and then saw all the benefits!!!! Gut health was amazing!!!! I am also struggling with breakouts due to rebalancing of hormones, but they would be way worse if not on a plant based lifestyle. You go Alice!!!! Preach!!!🙌🏻

  • Becca July 23, 2018 at 10:12 am

    You’re such an inspiration Alice! 😘

  • Vana Bobic Prizmic July 23, 2018 at 10:12 am

    Since my family found out that Serena Williams is vegan no one gives me advice anymore😎✌️💪💚

Leave a Reply

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