问题
I want to send a string with json content to a REST service. How can I convert a simple POJO to a json string? Normaly I would use Gson to do this:
My class that I want to convert:
public class UserMdl {
String name;
String pwHash;
//Constructur, getter and setter....
}
And my code to do this:
UserMdl userMd = new UserMdl("name", "pwHash");
Gson gson = new Gson();
String json = gson.toJson(userMdl);
However I cannot get gson to work with PlayN in the HTML build. It only works in the Java build. And I cannot figure out how to do this with the PlayN.json() stuff.
来源:https://stackoverflow.com/questions/9045455/how-do-i-convert-a-pojo-to-json-in-playn