###前提・実現したいこと
Androidでgoogle/gsonライブラリを利用してシステムを構築しています。
そこで、メンバにInterfaceを持つクラスのデシリアライズができないかと思案しております。
何か良い方法はないでしょうか?
###発生している問題・エラーメッセージ
JNI DETECTED ERROR IN APPLICATION
###該当のソースコード(実際のコードではなく、構成を示したものです。)
Json
1{ 2 "tests": [ 3 { 4 "x": 1 5 }, 6 { 7 "x": 2 8 } 9 ] 10}
Java
1public interface Itest 2{ 3 int getX(); 4 void setX(int x); 5} 6 7public class test impliments Itest 8{ 9 @SerializedName("x") 10 private int _x; 11 12 public int getX() {return _x}; 13 public void setX(int x) {_x = x}; 14} 15 16public class test2 17{ 18 // Itestをtestクラスにすれば実行可能。 19 @SerializedName("tests") 20 private List<Itest> tests; 21} 22 23public void execute(String jsonStr) 24{ 25 Gson gson = new Gson(); 26 27 // JSONからtestへの変換したいがエラー発生 28 test str = gson.fromJson(jsonStr, test.class); 29} 30 31
###補足情報
あなたの回答
tips
プレビュー