Last active
July 4, 2016 21:52
-
-
Save Magnagames/36f610fe5b713fbcc4dcc31c6eeae7a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sing System; | |
using UnityEngine; | |
using System.Collections; | |
public class JsonMapper | |
{ | |
static JsonMapper() | |
{ | |
LitJson.JsonMapper.RegisterExporter<float>((obj, writer) => writer.Write(Convert.ToDouble(obj))); | |
LitJson.JsonMapper.RegisterExporter<decimal>((obj, writer) => writer.Write(Convert.ToString(obj))); | |
LitJson.JsonMapper.RegisterImporter<double, float>(input => Convert.ToSingle(input)); | |
LitJson.JsonMapper.RegisterImporter<int, long>(input => Convert.ToInt64(input)); | |
LitJson.JsonMapper.RegisterImporter<string, decimal>(input => Convert.ToDecimal(input)); | |
// Debug.Log ("Mappingします"); | |
} | |
public static T ToObject<T>( string json ) | |
{ | |
return LitJson.JsonMapper.ToObject<T>( json ); | |
} | |
public static string ToJson( object obj ) | |
{ | |
return LitJson.JsonMapper.ToJson ( obj ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment