Last active
December 12, 2015 07:28
-
-
Save Kogarasi/4736316 to your computer and use it in GitHub Desktop.
JsonFxのデコード時のクラス定義を楽にしたい。
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
using JsonFx.Json; | |
public class SimpleGeneric { | |
// 呼び出し側 | |
public void hoge(){ | |
var decodeObject = simpleDecode( "{ a:1; }", new { a=1 } ); // 第二引数は型の指定 | |
} | |
public T simpleDecode<T>( string jsonString, T _type ){ | |
return JsonReader.Deserialize<T>( jsonString ); | |
} | |
} | |
// できるかなと思ったら、匿名クラスにはコンストラクタがないのでJsonFx内で例外が投げられて詰む |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment