-2

我是安卓新手。
我想将 JSON 对象转换为特定的类对象。
就像

TestClass test = (TestClass) jsonObject.

可能吗?

4

3 回答 3

4

Take a look at on GSON (http://code.google.com/p/google-gson/), or parse the JSON yourself

于 2013-12-06T14:10:43.127 回答
0

简单的铸造是不可能的。您应该从 JSON 对象中获取所有值,并使用 getter 和 setter 方法将值设置为其他类的对象。

于 2013-12-06T14:12:55.713 回答
0

请用这个,它会解决你的问题。

http://kylewbanks.com/post/show/Tutorial-Android-Parsing-JSON-with-GSON 

http://huluyige.blogspot.in/2013/02/android-code-snippetusing-gson-to-parse.html
于 2013-12-06T14:33:09.110 回答