Giter VIP home page Giter VIP logo

litjson's Introduction

LitJSON

A .Net library to handle conversions from and to JSON (JavaScript Object Notation) strings flavoured for the Unity3D engine.

Feature log

UnityEngine types

These already work out of the box

JsonMapper.ToJson( AnimationCurve.EaseInOut(0,0,1,1) );

Further adaptions allow to pass UnityEngine types directly to the mapper:

JsonMapper.ToJson( Vector2.zero ); // Output { "x" : 0, "y" : 0 }
JsonMapper.ToJson( Vector3.one );  // Output { "x" : 1, "y" : 1, "z" : 1 }
JsonMapper.ToJson( Vector4.one );  // Output { "x" : 1, "y" : 1, "z" : 1, "w" : 1 }
JsonMapper.ToJson( Quaternion.identity );  // Output { "x" : 0, "y" : 0, "z" : 0, "w" : 0 }
JsonMapper.ToJson( Matrix4x4.zero );  // Output { "m33" : 0, .. }
JsonMapper.ToJson( Color.green );  // Output { "r" : 0, "g" : 1, "b" : 0, "a" : 1 }

JsonMapper.ToJson( Ray );  // Output { "origin" : {V3}, "direction" : {V3} }
JsonMapper.ToJson( RaycastHit );  // Output { .. }

Of course reading back in also works:

var v2 = JsonMapper.ToObject<Vector2>( "{\"x\":0,\"y\":0}" ); 
var v3 = JsonMapper.ToObject<Vector3>( "{\"x\":0,\"y\":0,\"z\":1}" ); 
..

float (Single) and long (Int64) types

This fork includes this patch for serializing float(Single) and long(Int64) types from this pull request .

Build with Mono Develop / Xamarin Studio / Visual Studio / ..

  1. Create a solution & Library project within your IDE and reference all files from /src/LitJson .
  2. Add a configuration called Unity3D Project > Options > Build > Compiler and add Define Symbol UNITY3D .
  3. Reference the UnityEngine.dll from your Unity installation folder .
  4. Build the project .

Original README

The original README did move to README-ORIGINAL.md containing make instructions and license information.

litjson's People

Contributors

lbv avatar whoo24 avatar michaelbartnett avatar mickeykim avatar ht-friedrich avatar mviranyi avatar sonic3d avatar

Watchers

James Cloos avatar Chen Chen 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.