{"id":13676936,"url":"https://github.com/applejag/Newtonsoft.Json-for-Unity.Converters","last_synced_at":"2025-04-29T07:34:03.960Z","repository":{"id":43273885,"uuid":"234934905","full_name":"applejag/Newtonsoft.Json-for-Unity.Converters","owner":"applejag","description":"Converters of common Unity types for Newtonsoft.Json. Goes hand in hand with jilleJr/Newtonsoft.Json-for-Unity","archived":false,"fork":false,"pushed_at":"2024-03-01T10:17:41.000Z","size":641,"stargazers_count":357,"open_issues_count":14,"forks_count":39,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T13:00:55.843Z","etag":null,"topics":["hacktoberfest","newtonsoft-json","unity-package-manager","unity3d","unity3d-plugin","upm"],"latest_commit_sha":null,"homepage":"https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/applejag.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"newtonsoftjson-for-unity"}},"created_at":"2020-01-19T17:07:17.000Z","updated_at":"2025-04-18T15:29:12.000Z","dependencies_parsed_at":"2023-12-23T12:27:18.833Z","dependency_job_id":"8cc02ea3-3ce1-4699-83a3-4f5ec3bb8b8d","html_url":"https://github.com/applejag/Newtonsoft.Json-for-Unity.Converters","commit_stats":null,"previous_names":["applejag/newtonsoft.json-for-unity.converters","jillejr/newtonsoft.json-for-unity.converters"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applejag%2FNewtonsoft.Json-for-Unity.Converters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applejag%2FNewtonsoft.Json-for-Unity.Converters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applejag%2FNewtonsoft.Json-for-Unity.Converters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applejag%2FNewtonsoft.Json-for-Unity.Converters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/applejag","download_url":"https://codeload.github.com/applejag/Newtonsoft.Json-for-Unity.Converters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251456073,"owners_count":21592290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","newtonsoft-json","unity-package-manager","unity3d","unity3d-plugin","upm"],"created_at":"2024-08-02T13:00:34.920Z","updated_at":"2025-04-29T07:33:58.944Z","avatar_url":"https://github.com/applejag.png","language":"C#","funding_links":["https://opencollective.com/newtonsoftjson-for-unity"],"categories":["C#"],"sub_categories":[],"readme":"# Unity Converters for Newtonsoft.Json\n\n[![openupm](https://img.shields.io/npm/v/jillejr.newtonsoft.json-for-unity.converters?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/jillejr.newtonsoft.json-for-unity.converters/)\n[![CircleCI](https://img.shields.io/circleci/build/gh/applejag/Newtonsoft.Json-for-Unity.Converters/master?logo=circleci\u0026style=flat-square)](https://circleci.com/gh/applejag/Newtonsoft.Json-for-Unity.Converters)\n[![Codacy grade](https://img.shields.io/codacy/grade/de7041b5f9f9415a8add975d1b8a9fcf?logo=codacy\u0026style=flat-square)](https://www.codacy.com/manual/jilleJr/Newtonsoft.Json-for-Unity.Converters?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=jilleJr/Newtonsoft.Json-for-Unity.Converters\u0026amp;utm_campaign=Badge_Grade)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](/CODE_OF_CONDUCT.md)\n\nThis package contains converters to and from common Unity types. Types such as\n**Vector2, Vector3, Matrix4x4, Quaternions, Color, even ScriptableObject,**\n*and many, many more.*\n(See the [full compatibility table of all +50 supported Unity types][doc-compatability-table])\n\n## Dependencies\n\n### Newtonsoft.Json packages\n\nThis package requires the `Newtonsoft.Json.dll` file to be present in your\nproject. So it **does not have to be used with my\n`jillejr.newtonsoft.json-for-unity` package!** I recognize that there are too\nmany Newtonsoft.Json forks and variants out there in the Unity eco-system.\n\nThis package can be combined with any of the following:\n\n- Unity's fork of my fork Newtonsoft.Json package:\n  [`com.unity.nuget.newtonsoft-json@3.0.1`](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.0/manual/index.html) \n  *(recommended)*\n\n- My own fork of JamesNK's original Newtonsoft.Json repo:\n  [jilleJr/Newtonsoft.Json-for-Unity](https://github.com/jilleJr/Newtonsoft.Json-for-Unity)\n\n- SaladLab's fork: [SaladLab/Json.Net.Unity3D](https://github.com/SaladLab/Json.Net.Unity3D)\n\n- ParentElement's Assets Store package: \u003chttps://www.parentelement.com/assets/json_net_unity\u003e\n\n- *Any other source, such as having the `Newtonsoft.Json.dll` files inside your\n  Assets folder, as long as it declares the base `Newtonsoft.Json` types.*\n\nSince v3.0.1 of Unity's fork (of my fork) of Newtonsoft.Json, they are now\npromising a maintained version with official support by Unity's own dev\nteam. See installation instructions here: [Install official UPM package](https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Install-official-via-UPM)\n\n\u003e Do note that I've changed my GitHub username from jilleJr to applejag.\n\u003e Repository URLs automatically get redirected.\n\u003e\n\u003e I will not however rename the NPM/UPM/Cloudsmith packages.\n\n### Newtonsoft.Json versions\n\nThere's no hard linking towards a specific version. The package has been tested\nand works as-is with Newtonsoft.Json 10.0.3, 11.0.2, 12.0.3 and 13.0.1.\n\nThis package has not been tested towards Newtonsoft.Json versions older than\nv10.0.3, though the API has not changed much in a long time so it should be\nfine to use even as old versions as Json .NET v8.0.1 without any troubles.\n\nIf you have any troubles with using this package with a specific version of\nNewtonsoft.Json, then don't fray in opening an [issue][issue-create] so we can\nresolve it.\n\n## Installation\n\n### OpenUPM ![OpenUPM icon](Doc/images/openupm-icon-16.png)\n\nAdd the [jillejr.newtonsoft.json-for-unity.converters](https://openupm.com/packages/jillejr.newtonsoft.json-for-unity.converters/)\n\u003cabbr title=\"OpenUPM: A very popular open source Unity package registry for Unity Package Manager (UPM) packages\"\u003eOpenUPM\u003c/abbr\u003e\npackage:\n\n```sh\nopenupm add jillejr.newtonsoft.json-for-unity.converters\n```\n\nVisit the jilleJr/Newtonsoft.Json-for-Unity/wiki to [read more about\ninstalling/upgrading via OpenUPM][wiki-install-converters-via-git-in-upm].\n\n### Other\n\nVisit the jilleJr/Newtonsoft.Json-for-Unity/wiki for installation:\n\n- [Installation via \u003cabbr title=\"UPM: Unity Package Manager, included in Unity since 2018.1+\"\u003eUPM\u003c/abbr\u003e][wiki-install-converters-via-upm]\n- [Installation via Git in UPM][wiki-install-converters-via-git-in-upm]\n\n## What does it solve\n\nA lot of Unity types causes self-referencing loops, such as the Vector3 type.\nWhile serializing the value `new Vector3(0,1,0)`, Newtonsoft.Json will start\nwriting:\n\n```json\n{\n  \"x\": 0,\n  \"y\": 1,\n  \"z\": 0,\n  \"normalized\": {\n    \"x\": 0,\n    \"y\": 1,\n    \"z\": 0,\n    \"normalized\": {\n      \"x\": 0,\n      \"y\": 1,\n      \"z\": 0,\n      \"normalized\": {\n        \"x\": 0,\n        \"y\": 1,\n        \"z\": 0,\n        \"normalized\": {\n          ...\n        }\n      }\n    }\n  }\n}\n```\n\n*and so on, until \"recursion\" error..* But there are also some types such as the\n`UnityEngine.RandomState` that has its state variables hidden.\n\nThe converters in this package takes care of these issues, as well as many more.\n\n### Sample error without this package\n\nGiven this piece of code:\n\n```csharp\nusing UnityEngine;\nusing Newtonsoft.Json;\n\npublic class NewBehaviour : MonoBehaviour {\n    void Start() {\n        var json = JsonConvert.SerializeObject(transform.position);\n        Debug.Log(\"Position as JSON: \" + json);\n    }\n}\n```\n\nThen the following is shown:\n\n![Error in Unity Console window](Doc/images/console-without-package.png)\n\n```log\nJsonSerializationException: Self referencing loop detected for property 'normalized' with type 'UnityEngine.Vector3'. Path 'normalized'.\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:347)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContainerContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract\u0026 memberContract, System.Object\u0026 memberValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:552)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:486)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:181)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:486)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:181)\nNewtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:96)\nNewtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:1146)\nNewtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:1046)\nNewtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:665)\nNewtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:614)\nNewtonsoft.Json.JsonConvert.SerializeObject (System.Object value) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:530)\nSample.Start () (at Assets/Sample.cs:18)\n```\n\n### Sample with this package\n\nSame `NewBehaviour` script as above, but just by adding this package you instead\nsee:\n\n![Debug message in Unity Console window](Doc/images/console-with-package.png)\n\n```log\nPosition as JSON: {\"x\":201.0,\"y\":219.5,\"z\":0.0}\nUnityEngine.Debug:Log(Object)\nSample:Start() (at Assets/Sample.cs:19)\n```\n\n## Configuring converters\n\nThis package automatically adds all its converters to the\n[`JsonConvert.DefaultSettings`](https://www.newtonsoft.com/json/help/html/DefaultSettings.htm)\nif that value has been left untouched.\n\nIf you want to only use a certain subset of the converters, or perhaps add in\nsome of your own custom converters, then you have some options that will be\nexplored just below here.\n\n### Default settings\n\n- Use the custom Unity contract resolver that looks for `[SerializeField]`\n  attributes.\n\n- Use only some of the Newtonsoft.Json converters, namely:\n\n  - [StringEnumConverter](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Converters_StringEnumConverter.htm)\n  - [VersionConverter](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Converters_VersionConverter.htm)\n\n- Use all converters from this package.\n\n- Use all other converters defined outside the `Newtonsoft.Json` namespace.\n\n### Custom settings through code\n\nYou can override these defaults mentioned above in your code whenever you're\nserializing/deserializing. For example:\n\n```cs\nusing Newtonsoft.Json;\nusing Newtonsoft.Json.UnityConverters;\nusing Newtonsoft.Json.UnityConverters.Math;\n\nvar settings = new JsonSerializerSettings {\n    Converters = new [] {\n        new Vector3Converter(),\n        new StringEnumConverter(),\n    },\n    ContractResolver = new UnityTypeContractResolver(),\n};\n\nvar myObjectINeedToSerialize = new Vector3(1, 2, 3);\n\nvar json = JsonConvert.SerializeObject(myObjectINeedToSerialize, settings);\n```\n\n### Custom settings through config file\n\nSince v1.1.0 of this package, you can configure and override these defaults\nthrough a ScriptableObject that is saved at\n`Assets/Resources/Newtonsoft.Json-for-Unity.Converters.asset`.\n\nTo open the settings, click **\"Edit\"** in the top menu bar and select\n**\"Json\u003ci\u003e\u003c/i\u003e.NET converters settings...\"**\n\n![Configuring ScriptableObject config](Doc/images/configure-scriptableobject.png)\n\nWithin this settings page, you can enable or disable any of the converters you\nwish to include or omit by default.\n\nThese settings are only applied when you're using the default\nJsonSerializerSettings that this package has overridden. If you're setting the\nJsonSerializerSettings manually through code, as shown in the example above,\nthen all of these settings will be ignored.\n\n## Contributing\n\nThankful that you're even reading this :)\n\nIf you want to contribute, here's what you can do:\n\n- **Spread the word!** ❤ More users \u0026rarr; more feedback \u0026rarr; I get more\n  will-power to work on this project. This is the best way to contribute!\n\n- [Open an issue][issue-create]. Could be a feature request for a new converter,\n  or maybe you've found a bug?\n\n- [Tackle one of the unassigned issues][issue-list-unassigned]. If it looks like\n  a fun task to solve and no one is assigned, then just comment on it and say\n  that you would like to try it out.\n\n- Open a PR with some new feature or issue solved. Remember to ask before\n  starting to work on anything, so no two are working on the same thing.\n\n  Having a feature request or issue pop up and having the submitter suggesting\n  themselves to later add a PR for a solution is the absolute greatest gift\n  a repository maintainer could ever receive. 🎁\n\n## Changelog\n\nPlease see the [CHANGELOG.md][changelog.md] file inside this package.\n\n---\n\nThis package is licensed under The MIT License (MIT)\n\nCopyright (c) 2019 Kalle Fagerberg (jilleJr)  \n\u003chttps://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters\u003e\n\nSee full copyrights in [LICENSE.md][license.md] inside repository\n\n[license.md]: /LICENSE.md\n[changelog.md]: /CHANGELOG.md\n[wiki-install-converters-via-git-in-upm]: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Install-Converters-via-Git-in-UPM\n[wiki-install-converters-via-upm]: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Install-Converters-via-UPM\n[wiki-install-converters-via-openupm]: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Install-Converters-via-OpenUPM\n[doc-compatability-table]: Doc/Compatability-table.md\n[issue-create]: https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters/issues/new/choose\n[issue-list-unassigned]: https://github.com/jilleJr/Newtonsoft.Json-for-Unity.Converters/issues?q=is%3Aopen+is%3Aissue+no%3Aassignee\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapplejag%2FNewtonsoft.Json-for-Unity.Converters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapplejag%2FNewtonsoft.Json-for-Unity.Converters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapplejag%2FNewtonsoft.Json-for-Unity.Converters/lists"}