Java 如何使用GSON进行铸造
有没有办法使用GSON将json中的字符串值转换为int、long或double成员 我的意思是,我有一个json字符串,类似这样:Java 如何使用GSON进行铸造,java,json,casting,gson,Java,Json,Casting,Gson,有没有办法使用GSON将json中的字符串值转换为int、long或double成员 我的意思是,我有一个json字符串,类似这样: {'timestamp':'1243274283728', 'distanse':'122.1'} 我想将这个json字符串映射到以下类的对象: public class TestClass { public long timestamp; public double distance; } 提前谢谢你这不管用吗 TestClass obj = n
{'timestamp':'1243274283728', 'distanse':'122.1'}
我想将这个json字符串映射到以下类的对象:
public class TestClass
{
public long timestamp;
public double distance;
}
提前谢谢你这不管用吗
TestClass obj = new Gson().fromJson(
"{'timestamp':'1243274283728', 'distance':'122.1'}",
TestClass.class);
该死的。。。然后我在代码的其他地方遇到了另一个问题。非常感谢。