Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Ochreous · Aug 03, 2012 at 06:21 AM · c#jsonxmlcomparison

JSON vs XML for Unity C#

which Serialization method is best for Unity XML or JSON? I'm currently writing my scripts in C#.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Aug 03, 2012 at 05:53 PM 1
Share

What are you serialising for? Your own server etc.

avatar image Ochreous · Aug 03, 2012 at 10:45 PM 0
Share

To save int, bool, and float Values.

avatar image whydoidoit · Aug 03, 2012 at 10:46 PM 1
Share

Locally or to a server? You are best off with binary formatting for speed and size - use a text based format when sending data to a server or if you really want it to be human readable and editable.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by idunlop_oefun · Aug 03, 2012 at 11:28 PM

For pulling data from a server JSON is better because it's less bandwidth than XML - especially for mobile devices.

For storing user preferences, like a bool or int etc. use PlayerPrefs (see the documentation).

For storing things on disk it really depends on what your trying to accomplish. You can create your own format for binary files or read / write json data if needed.

If the amount of data I was trying to serialize was huge (i.e. a significant % of the devices capability) I'd probably want to use as compact a format as possible - which implies some sort of raw packed data format.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Aug 03, 2012 at 11:30 PM 0
Share

I'd just point out that binary formatter can serialize most classes to a compressed format that you don't have to make up yourself.

avatar image Bunny83 · Aug 03, 2012 at 11:38 PM 0
Share

Yes, generally the only good reason to use a humanreadable format is to make it humanreadable ;) For savegames it's usually unwanted to make it humanreadable, so a binary format is the best bet in such a case.

But as stated several times here, it depends on the situation. This is lika you ask what's the best car or what's the best hammer. There are very different models out there, it just depends on the usage.

avatar image Ochreous · Aug 04, 2012 at 02:16 AM 0
Share

Ok I will try to use a binary format Because I don't want it to be readable and editable. Are there any good tutorials on how to setup a binary format?

avatar image whydoidoit · Aug 04, 2012 at 02:19 AM 1
Share

See my answer here

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

XML parsing c# in unity 1 Answer

Start a game by reading the data from the xml 1 Answer

How to send data form to server using json in unity 1 Answer

C# Getting only the Name of the XML File and not the Directory of the XML File 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges