Thread: Why JSON?

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Location
    US
    Posts
    105
    Rep Power
    58

    Why JSON?


    I'm a bit confused...
    Having worked as a server side developer for several years, I work every day with xml.
    On the contrary, I have rarely come across JSON.

    Recently while attending a developers hangout, I was chastised for still writing xml and was told it's dead, obsolete, and JSON is the new XML.

    I asked why? The answers: It's easier, less overhead, more concise, it's used everywhere.

    My concern is... I don't ever deal with javascript or frontend langauges, so why should I be using JSON to transfer database data from one server to another for a backend script that utilizes in-house apis?

    Why should I be using JSON when XML and SOAP have proven just fine, in fact appear better structured and accurately defined?
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Just because it's the latest and greatest doesn't mean you have to use it. XML has advantages on JSON like comments, a difference between attributes and elements, and schemas. It's also supported absolutely everywhere while JSON is still catching up.

    Keep using XML if it's good for you.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Location
    US
    Posts
    105
    Rep Power
    58
    I admit, JSON is attractive for most situations, but I guess what grinds me is the fact that it has Javascript in its name!

    Javascript = client side (aside from ajax of course, where xml enters the scene)

    Perhaps I'm being immature by hesitating to submit, simply because Javascript is in its name, but it seems for code that client side developers will never read, then I shouldn't be using it. Not trying to start a war between front-end / back-end or SOA vs API, but genuinely curious. Don't plan on changing legacy code, but will consider for future projects.

    Thanks.
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Javascript also has "Java" in its name, but that doesn't mean only Java people should use it. Or that there's any relationship between the two whatsoever (which there isn't).

    The full acronym is "Javascript Object Notation" and if you think about that you can see how Javascript doesn't play an active role: it's simply the same notation that Javascript uses for its objects. It's a nice syntax, short, easy to read and write, looks familiar to what is used in many programming languages, so why not borrow it for use elsewhere? And that's really all that happened.

    You might as well dislike XML because it's what SOAP messages use. I don't use SOAP. I don't even like SOAP. Don't take that out of context. But that doesn't mean XML is worthless to me too.
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,782
    Rep Power
    4301
    JSON plays nice with Javascript, which is why many people like it. Other languages use similar syntax, so it is natural that they have parsers for JSON as well. It is also a more compact format than XML. However, XML is a better at document oriented info and JSON is better at data oriented info. XML also allows you to create new types, whereas JSON doesn't. They are aimed at solving different problems, so one may be better than the other in one scenario and the reverse may be true in another scenario.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2015
    Posts
    1
    Rep Power
    0

    XML - die, and don't come back


    It's ultra simple, and lightweight.
    It's here. People implemented it for browsers, databases, frameworks, and libraries. We use it for SPA updates, data store and data interchange.
    Some of us HATE XML

    1. XML got too big for its boots. It really needed to be taken down a peg, or ten. At first I liked XML, back in the days of DTDs. We lived in the dark ages when people really did use CSV for data interchange. XML came to the rescue. With it came schemas, massive specs, bloody programming languages written in XML! It got really ugly.
    2. The move to JSON is a bit like the move to node. As was explained to me years ago when I laughed and said "that's never going to happen" :- there are lots of JavaScript programmers out there, they will take to this like ducks to water.
    3. Compared to the bloat of XML, JSON is simple and easy.
    4. Nothing's perfect, JSON is a bit too simple (like ONE numeric datatype - you've got to be kidding us!). There are alternatives but none are nearly as well supported as JSON and XML. YAML, edn, JSON extensions, and others are improvements. Some alternatives go in the wrong direction by ditching human readable.
    5. I fear JSON will be with us for a long time. For so long as the browser dominates, JavaScript dominates the browser, and its pathetic so-called type system remains.

    JSON isn't the finished article. Something better will replace it, but that won't be XML. The dead will not reawaken, that particular winter's not coming back.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2015
    Location
    Navi Mumbai
    Posts
    3
    Rep Power
    0
    JSON is much simple than XML. JSON has a much smaller grammar and maps more directly onto the data structures used in modern programming languages.JSON ends up being much, much easier to traverse, identify, and read nodes than XML. XML methods are cumbersome and long to write.Easy in parsing, processing, validating in all languages.

IMN logo majestic logo threadwatch logo seochat tools logo