我是安卓新手。
我想将 JSON 对象转换为特定的类对象。
就像
TestClass test = (TestClass) jsonObject.
可能吗?
我是安卓新手。
我想将 JSON 对象转换为特定的类对象。
就像
TestClass test = (TestClass) jsonObject.
可能吗?
Take a look at on GSON (http://code.google.com/p/google-gson/), or parse the JSON yourself
简单的铸造是不可能的。您应该从 JSON 对象中获取所有值,并使用 getter 和 setter 方法将值设置为其他类的对象。
请用这个,它会解决你的问题。
http://kylewbanks.com/post/show/Tutorial-Android-Parsing-JSON-with-GSON
http://huluyige.blogspot.in/2013/02/android-code-snippetusing-gson-to-parse.html