我查看了大部分在线的可用教程,在Libgdx中使用Json,这看起来非常简单。但是,由于某种原因,json.toJson()不断返回一个两个单元格的数组,第一个包含{和第二个包含}。 我的代码是非常简单的:Libgdx,JSON:Json.tojson(object)不断返回{}
public class GameConfig {
public int screenWidth;
public int screenHeight;
public GameConfig() {
screenWidth = 800;
screenHeight = 600;
}
}
然后
String configAsText = json.toJson(zzz);//configAsText.value equals [0] = { and [1] = }
String configAsText = json.toJson(config, GameConfig.class);//nor this one
任何想法?
如何实例化json对象? –
你知道JSON是什么吗?它不是“两个单元格数组”,而是代表JSON中空对象的String ['}'。 – noone
Christian Cederquist < - 像这样Json json = new Json(); – coffeenet