سؤال

I am new in Android.
I want to do a cast JSON object to particular class object.
Just like

TestClass test = (TestClass) jsonObject.

Is it possible?

هل كانت مفيدة؟

المحلول 2

Simply casting is not possible. You should get all the values from the JSON Object and set the values to your Object of the other class using getter and setter methods.

نصائح أخرى

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

Please go with this one , it will solve your problem.

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

http://huluyige.blogspot.in/2013/02/android-code-snippetusing-gson-to-parse.html
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top