Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Question about XML [devs]

  1. #1
    Ranger themirror's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    258
    Rep Power
    0

    Question about XML [devs]

    Hello guys.
    I'm a C# developer and I am really curious to know why the decision to use XML files instead of JSON files.
    It is a unity default or what?

    JSON has many advantages over XML, in parsing time, generic arrays, etc.
    Since the 5.3.3 Unity update, there is a native parser for JSON that is way better than other 3rd party JSON parsers. There is any plans to change XML files to JSON files?

    Any other developers can see the whole purpose of using XML over JSON? Any noticeable advantages?

  2. #2
    Colony Founder The Gronk's Avatar
    Join Date
    Jun 2015
    Location
    Here
    Posts
    1,603
    Rep Power
    1
    I also develop with unity... among other things. I think they went with XML for simplicity, it's a lot easier for n00bs to read XML.

    JSON is also very unforgiving whereas with XML everything can pretty much be parsed individually so a single typo won't render the entire file unreadable.

    XML is also easier to extend than JSON.

    Personally I have a strong dislike for XML having used it many times before and given the choice I'd be using JSON but I can also see where in this case XML has certain advantages over JSON.

  3. #3
    Leader Tin's Avatar
    Join Date
    Feb 2014
    Location
    In between
    Posts
    5,060
    Rep Power
    1
    This ^

    If you feel the need to do more like, writing scripts, add assets or just go deeper check out sdx for your needs. Does a pretty decent job.

  4. #4
    Hunter ColdSteelRain's Avatar
    Join Date
    Jul 2017
    Location
    Dallas, TX
    Posts
    108
    Rep Power
    1
    On a small dev team, the choice between two similar approaches is most likely due to the preferences of whoever is doing the work.

    I will say that there are some very good tools for working in XML, and being able to do schema validation on files that your users may be editing is probably a good thing. I don't know if there's a way to do that in JSON. It might also be handy to be able to use XQuery/XPath in the code; again, I don't know if there's a similar feature if you use JSON.

  5. #5
    Refugee
    Join Date
    Jan 2017
    Posts
    18
    Rep Power
    0
    Quote Originally Posted by themirror View Post
    Hello guys.
    I'm a C# developer and I am really curious to know why the decision to use XML files instead of JSON files.

    I suggested it. Done deal.

  6. #6
    Colony Founder Vedui's Avatar
    Join Date
    Nov 2016
    Posts
    1,127
    Rep Power
    1
    I think many people who delve into the config files to change and tweak things are probably happy it's XML and not JSON files, simply as it's more straightforward and easy to read in my view. Though some claim JSON is easier to read :P

    Things like efficiency and parsing times wouldn't be a big issue anyways, it's loaded once, then used, and not continually accessed I believe. At this point in time, switching over from XML to JSON would be pointless unless there was a particular things which XML wasn't allowing which was needed. Doing it just because a unity version (later than initial design) happened to have better support for it, if it didn't actually make any change to how the game runs, also wouldn't make sense.

    JSON also doesn't allow for commenting the files, something which XML does no?. Well, normally anyways, I guess you could strip it, but then it's not really JSON is it. That's extremely helpful in XML files which users will be editing.

    /V Guide to Modded Beasts - Direwolf and Zombie Dog!

  7. #7
    Refugee
    Join Date
    Apr 2018
    Location
    780 Church Street Elmhurst, NY 11373
    Posts
    6
    Rep Power
    0
    Quote Originally Posted by Rust Buddy View Post
    I suggested it. Done deal.
    Hey, I am beginner level developer, I thought the same things even still now. Can you please tell me what your suggestion regards this issue? Glad if you.

  8. #8
    Hunter Qyzer's Avatar
    Join Date
    Jan 2017
    Posts
    107
    Rep Power
    0
    While I fall strongly into the "avoid XML like the plague" camp and I love JSON overall, I think something in the middle (YAML or perhaps JSON5) would be my preference if I was involved in the dev side of a project like this. Though I have no idea how Unity deals with any of it (I can't yet get my work to pay me to work with Unity ).

    That said, I hold my breath and work in the XML because I love this game enough to deal with even it's wartiest warts when I'm modding.

  9. #9
    Colony Founder The Gronk's Avatar
    Join Date
    Jun 2015
    Location
    Here
    Posts
    1,603
    Rep Power
    1
    Quote Originally Posted by Qyzer View Post
    While I fall strongly into the "avoid XML like the plague" camp and I love JSON overall, I think something in the middle (YAML or perhaps JSON5) would be my preference if I was involved in the dev side of a project like this. Though I have no idea how Unity deals with any of it (I can't yet get my work to pay me to work with Unity ).

    That said, I hold my breath and work in the XML because I love this game enough to deal with even it's wartiest warts when I'm modding.
    You can usually find a library you can incorporate into your project although since unity uses an ancient version of mono sometimes you have to fix and recompile the library to do so.

  10. #10
    Ranger themirror's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    258
    Rep Power
    0
    Thanks for the answers guys, sorry for the delay to reply.

  11. #11
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,794
    Rep Power
    1
    json is better for data transfer, xml is better for manually editing

  12. #12
    Fun Pimps Staff Gazz's Avatar
    Join Date
    Jun 2014
    Location
    In your brains. Thinking your thoughts.
    Posts
    7,599
    Rep Power
    2
    It's more an issue of accessibility.
    Not all developers (or modders) are programmers or even numbers persons.

    Up until A16 XML was used exclusively to store content data and there it makes no difference whatsoever.
    A17 has "scripting" in XML (Down boys! It's a handful of simple logic functions and conditions) but we're moving towards beta and redoing the declaration of every bit of content over a preference... nope.

  13. #13
    Ranger themirror's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    258
    Rep Power
    0
    Thanks for the reply @Gazz

  14. #14
    Colony Founder The Gronk's Avatar
    Join Date
    Jun 2015
    Location
    Here
    Posts
    1,603
    Rep Power
    1
    Quote Originally Posted by Gazz View Post
    It's more an issue of accessibility.
    Not all developers (or modders) are programmers or even numbers persons.

    Up until A16 XML was used exclusively to store content data and there it makes no difference whatsoever.
    A17 has "scripting" in XML (Down boys! It's a handful of simple logic functions and conditions) but we're moving towards beta and redoing the declaration of every bit of content over a preference... nope.
    Damn you!

    That's like telling someone you have cake without telling them it's "carrot" cake. :-)

    On a more serious note, it'll be interesting to see how that's implemented.

  15. #15
    Hood Ornament Gamida's Avatar
    Join Date
    May 2015
    Location
    The Rock
    Posts
    3,363
    Rep Power
    1
    Quote Originally Posted by The Gronk View Post
    Damn you!

    That's like telling someone you have cake without telling them it's "carrot" cake. :-)

    On a more serious note, it'll be interesting to see how that's implemented.
    I actually like carrot cake.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •