Search Unity

What are the major benefits of JSONUtility usage?

Discussion in 'Scripting' started by jeremy_crowell, Sep 16, 2018.

  1. jeremy_crowell

    jeremy_crowell

    Joined:
    Jul 21, 2018
    Posts:
    36
    Hello,

    If I have a bunch of game items, let's say 60 items with different properties(e.g. weight, color, sound and etc) do I need to save them in json or I can keep them in array without serialization?

    What benefit I will get if I save array of 60 objects in json? I suppose it's just a question of space, right?

    Thank you in advance
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    2,147
    If you're not saving and loading them, there's little difference. At some point you're going to have to turn the data into "real" objects anyways.
     
    jeremy_crowell likes this.
  3. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    682
  4. jeremy_crowell

    jeremy_crowell

    Joined:
    Jul 21, 2018
    Posts:
    36

    Yap, just came across this situation a little bit later after I posted the question. Without serialization I can't save and load them. Thanks for your confirmation.
     
  5. jeremy_crowell

    jeremy_crowell

    Joined:
    Jul 21, 2018
    Posts:
    36
    Update. I didn't know that unity doesn't support serialization of array. It's really weird. Such a big engine and I need to use external class to serialize my array of custom objects.
     
    rakkarage likes this.