Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Unity.Serialization or Json.Net

Discussion in 'Scripting' started by Yuyc001, Sep 4, 2023.

  1. Yuyc001

    Yuyc001

    Joined:
    Mar 22, 2023
    Posts:
    4
    Hi, I'm currently learning how to develop a save and load system for my game. I've come across two packages that can serialize my C# objects to JSON format at runtime: Json.Net and Unity.Serialization. I'm wondering which one would be a better choice. Thank you for your help!
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,383
    Unity.Serialization is GREAT for binary!
    The Json API however is a complete ... :mad: !!
    It demands that you know every detail of the json format. Exactly the opposite that you want from a json API, or if I were to want to build Json myself bit by bit I'd really much rather use StringBuilder over Unity's JsonSerialization.

    In any case, almost everyone is using NewtonSoft.Json.
    There's also a Unity package for that: https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@2.0/manual/index.html
     
    Yuyc001 likes this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,224
    Yuyc001 likes this.
  4. Yuyc001

    Yuyc001

    Joined:
    Mar 22, 2023
    Posts:
    4
    Thank you for the information, that helps a lot! I think I'll try to build a simple abstraction layer between the serialization library and my game code in case I need to make changes.