XML vs JSON

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    XML vs JSON

    Hi all,

    I am interested in the forums collective thoughts on XML vs JSON..

    When to use one over the other ?

    Relative benefits of both, weaknesses of both..

    Thanks in advance

    Regards Purple
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    XML:
    more widely used.
    more support.
    too verbose.
    good for imbricated data (documents)
    slow parser speed in browsers

    JSON:
    older.
    less used.
    more efficient parsers on average.
    not good for nested/imbricated data.

    Haven't used jsON myself so can't say much more.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      The thing I like the most about JSON is that it (for the most part) 'just works'. You can use json_encode() on the PHP side, and JavaScript can simply eval() the result.

      Or in reverse, you have {object}.toSour ce() and json_decode().

      Of course, you could write your own serialize() function in JavaScript (anybody want me to post mine?)...

      Comment

      Working...