Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

This project vs com.unity.nuget.newtonsoft-json #145

Open
applejag opened this issue Dec 12, 2021 · 5 comments
Open

This project vs com.unity.nuget.newtonsoft-json #145

applejag opened this issue Dec 12, 2021 · 5 comments

Comments

@applejag
Copy link
Owner

applejag commented Dec 12, 2021

(Last updated: 2022-03-03)

Is this package compatible with com.unity.nuget.newtonsoft-json?

No. Sadly not. Reason for this is the combination of:

  • Cannot have multiple .NET assemblies with the same name in a project at the same time.

  • All files in Unity's and my package has the same GUIDs (in their .dll.meta, .md.meta, .asmdef, etc).

Plans on making it compatible with com.unity.nuget.newtonsoft-json?

There's no plan in making them compatible. There's too many techincal limitations in play here that makes it practically impossible.

There are however plans on resolving this with some Unity devs. I've had a years long discussion with some Unity developers on the topic almost since the dawn of this fork. Fun trivia: the same discussion that com.unity.nuget.newtonsoft-json@v2 was created from to begin with.

Different with this project and com.unity.nuget.newtonsoft-json?

Unity's "official" Newtonsoft.Json package, starting with version 2.0.0-preview.1, is a fork of this repo. They have practically "just" republished my fork as their own.

Just so there's no confusion: It's in their full right to do so. And in fact, one of their super kind developers reached out beforehand just to confirm it would be OK with me, something they didn't have to do, but I really appreciate that they did.

Is com.unity.nuget.newtonsoft-json safe to use?

Edit 2022-03-03: Since late February 2022, starting with v3.0.0 of their package, Unity has now committed to maintaining their fork to keep it up-to-date with the upstream JamesNK/Newtonsoft.Json, providing customer support, as well as publishing their package publicly inside Unity's official UPM registry.

They are just about to make it public, but until then, you can follow my guide on install the official Newtonsoft.Json UPM package over at my wiki.

Latest news on Unity adopting jilleJr/Newtonsoft.Json-for-Unity for real?

Edit 2022-03-03: It is now a reality! My fork can now be considered dead, in favor of Unity's package, starting with v3.0.0: https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.0/manual/index.html

For the long run, Unity is working hard on the .NET 6 adoption and for the long run are looking for using .NET's built in System.Text.Json package instead, leaving end-users free to choose between Newtonsoft.Json or System.Text.Json. Read more: https://forum.unity.com/threads/unity-future-net-development-status.1092205/

What's the future of jilleJr/Newtonsoft.Json-for-Unity?

Edit 2022-03-03: I am officially deprecating this package in favor of Unity's package, as stated above.

I will stop providing:

  • Bug fixes
  • New features
  • New documentation

However, I will still provide:

  • Support from questions asked in discussions or issues. However, please refer to the https://forum.unity.com/ or their issue tracker for better support by Unity employees.
  • Package downloads for existing versions. No need for me to take down the Cloudsmith package or the branches here on GitHub. They will live on, as long as Cloudsmith and GitHub keeps living on.
@applejag applejag pinned this issue Dec 12, 2021
@scott-lin
Copy link

I was using jilleJr for json in an old Unity project (year or so ago), and I've come back to the project recently. I was interested in updating the project's Unity editor version from 2019.4.12f1 LTS to 2020.3.26f1 LTS. However, I noticed com.unity.nuget.newtonsoft-json was now in play with the updated Unity editor.

Am I correct in assuming there's no way to remove com.unity.nuget.newtonsoft-json package since it's required by the latest editor?

@applejag
Copy link
Owner Author

applejag commented Jan 14, 2022

@scott-lin Am I correct in assuming there's no way to remove com.unity.nuget.newtonsoft-json package since it's required by the latest editor?

Yeah, correct.

In detail: while the core Unity editor itself does not depend on com.unity.nuget.newtonsoft-json, there are so many of the basic packages that does depend on it.

If you were to empty out your Packages/manifest.json, then no com.unity.nuget.newtonsoft-json would be loaded. But that's extremely unpractical. I do not know which packages exactly that depend on it, but all I know is that there are multiple ones that do.

@scott-lin
Copy link

Very sad news. 😢

Unity requires Editor 2020.3+ for using their multiplayer Netcode solutions, so I'm in a hard spot.

From what I can tell, Unity's built in JSON utilities (aka UnityEngine.JsonUtility.FromJson) cannot deserialize many JSON strings that are supported by Newtonsoft.Json. For example, strings with newlines.

Sorry to ask about "competitors", but do you know of any other JSON tooling for Unity that may be alternatives?

@applejag
Copy link
Owner Author

@scott-lin hey don't worry! It's a valid question.

A few years ago I researched and created a list of alternatives. So mind you, it's probably quite out of date. But here they are:

Or if you don't mind changing format, trying out XML might be a valid solution as .NET has had built in support for ages:

Or if you want to try other binary formats, then maybe something like Cap'n Proto, Google's protobuf, or Apache Thrift might be good:

I've not tried any of the above packages, so you'll have to verify their Unity and IL2CPP support yourself. Hope you find a solution!

@applejag
Copy link
Owner Author

applejag commented Mar 3, 2022

Big news: Unity has now officially adopted the package 🎉🎊🎉

I've updated the issue description with more information

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants