Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programming
  3. I've seen XML parsers that will convert element content from strings to native types by default.

I've seen XML parsers that will convert element content from strings to native types by default.

Scheduled Pinned Locked Moved Programming
9 Posts 6 Posters 1 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P This user is from outside of this forum
    P This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

    I've seen XML parsers that will convert element content from strings to native types by default. So "0" becomes an int, "true" becomes a boolean, and "null" becomes an actual null. I had to take extra steps to keep everything as a string unless explicitly told not to.

    JSON does not have this problem, BTW.

    C 1 Reply Last reply
    0
    • System shared this topic on
    • P [email protected]

      I've seen XML parsers that will convert element content from strings to native types by default. So "0" becomes an int, "true" becomes a boolean, and "null" becomes an actual null. I had to take extra steps to keep everything as a string unless explicitly told not to.

      JSON does not have this problem, BTW.

      C This user is from outside of this forum
      C This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      I don't think anyone actually chooses XML. There's no reason to use it over JSON unless you need to.

      chairmanmeow@programming.devC P B L 4 Replies Last reply
      0
      • C [email protected]

        I don't think anyone actually chooses XML. There's no reason to use it over JSON unless you need to.

        chairmanmeow@programming.devC This user is from outside of this forum
        chairmanmeow@programming.devC This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        The entirety of the banking world uses XML very heavily, as it's part of the SWIFT standards.

        C 1 Reply Last reply
        0
        • chairmanmeow@programming.devC [email protected]

          The entirety of the banking world uses XML very heavily, as it's part of the SWIFT standards.

          C This user is from outside of this forum
          C This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          I didn't say that it's not used. I say that you shouldn't if you have the option.

          If the entire X world uses Y technology. You have no choice other than using Y technology.

          1 Reply Last reply
          0
          • C [email protected]

            I don't think anyone actually chooses XML. There's no reason to use it over JSON unless you need to.

            P This user is from outside of this forum
            P This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            Really? Right in front of my AJAX?

            1 Reply Last reply
            0
            • C [email protected]

              I don't think anyone actually chooses XML. There's no reason to use it over JSON unless you need to.

              B This user is from outside of this forum
              B This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              json is fine as a serialization format for things that need to be text, but it's not great as something that gets edited by hand.

              not that I enjoy xml, but writing long strings in json is even worse. xml I can write multiline strings as a first class entity.

              I can add a comment to an xml document, json i have to write something hacky like "//": "my comment" and hope whatever is consuming it doesn't care.

              there's just as many problems with json parsers, since most but not all of them treat numbers as js numbers, which are basically floats. you can't rely on an arbitrary consumer having support to parse ints above a certain size so you just have to make everything a string and hope.

              json allows duplicate keys, but they get overridden by the last occurrence. you can't round trip json without losing something. you can't rely on just seeing a key value in json text and that being correct since there could be another later. doesn't come up often but it's there.

              1 Reply Last reply
              0
              • C [email protected]

                I don't think anyone actually chooses XML. There's no reason to use it over JSON unless you need to.

                L This user is from outside of this forum
                L This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                XML can validate itself and there's the self-documenting WSDL; so while it has more overhead and an ugly syntax it can make for a more stable and earlier to understand API for your API's consumers.

                C 1 Reply Last reply
                0
                • L [email protected]

                  XML can validate itself and there's the self-documenting WSDL; so while it has more overhead and an ugly syntax it can make for a more stable and earlier to understand API for your API's consumers.

                  C This user is from outside of this forum
                  C This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #8

                  This point is always stated about XML as if it were the most important part of choosing XML.

                  But jsonschema exists. It has the same capability.

                  L 1 Reply Last reply
                  0
                  • C [email protected]

                    This point is always stated about XML as if it were the most important part of choosing XML.

                    But jsonschema exists. It has the same capability.

                    L This user is from outside of this forum
                    L This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #9

                    Ah but... Nobody uses that!
                    Because then you wouldn't choose JSON

                    1 Reply Last reply
                    0
                    • System shared this topic on
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups