Code Monkey home page Code Monkey logo

unity-json-converters's Introduction

Unity Json.NET Converters

A drop-in solution providing custom converters for Unity types, no configuration required.

The problem

Newtonsoft Json, which has been officially supported as a Unity package as com.unity.nuget.newtonsoft-json, has trouble serializing most native Unity types such as Color, Vector2 , Vector3 and many more. This is due to self-references in the struct types Unity uses, which runs Json.NET into an infinite serialization loop.

The solution

This package adds custom converters for these Unity types into your project and automatically adds them to the default configuration of Newtonsoft Json in both editor and runtime. No configuration required - plug and play.

Installation

  1. In your package manager (Window > Package Manager) choose the +.
  2. Select "Add from git URL"
  3. Enter https://github.com/AbandonedCrypt/unity-json-converters.git and go.
  4. You are done and ready to de-/serialize

Supported Unity types

Currently only the following are supported, but with time, all will be added.

  • Color
  • Vector2
  • Vector3
  • Vector4

What if i want to override a specific converter?

You can do so by modifying the default settings in your project and adding the converter using the OverwriteAll extension method on the JsonSerializerSettings.Converters collection. It does not matter if that modification gets executed before or after this package.

Why this one?

Its stupidly simple. Even a beginner could maintain a fork of this, were I to stop doing so.

unity-json-converters's People

Contributors

abandonedcrypt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.