I am developing a client-server Model-based application in which client is in Android and server in PHP.
I want to transfer product information for example Name,Price,Description, from client to server. I have read that through marshaling/unmarshaling or serialization it can be achieved but all tutorials and example are in Java. But I need in Android. Please guide me to implement in Android. Or there is any other way to implement? Any example will b appreciated. Thanks.
I'm using SimpleXML http://simple.sourceforge.net/
And I'm happy with it, it's a light jaxb like!
Have a look on json. Google provides a nice Library called "Gson" for that.
To stick to your example, a json representation send from your server via http could be:
In your app, you have a class MyObject.class
Then you can just do:
and voila, made an object out of the string in one line. Just be sure that the variables have the same name in the json representation and the class, then Gson does all the work for you. You can also make a String representation out of the object with
String jsonString = new Gson().toJson(obj)
.