如何使用默认读取器和自定义写入器实现LibGDX Json.Serializable [英] How to implement LibGDX Json.Serializable with default reader and custom writer

查看:118
本文介绍了如何使用默认读取器和自定义写入器实现LibGDX Json.Serializable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用默认的LibGDX Json解串器读取JSON文件,但是实现了自己的方法来将类写回到JSON文件.当我实现Json.Serializable时,它迫使我同时实现读写方法.如何在read方法中调用默认的反序列化器?

I would like to use the default LibGDX Json deserializer to read in a JSON file, but implement my own method for writing the class back out to a JSON file. When I implement Json.Serializable, it forces me to implement both the read and write methods. How can I call the default deserializer in the read method?

推荐答案

我一直在寻找相同的东西,最后这个实现的read方法对我有用,我希望它对您也有用:

I was looking for the same thing, finally this implemented read method worked for me, I hope it works for you too:

@Override
public void read(Json json, JsonValue jsonMap) {

    json.readFields(this, jsonMap);
}

这篇关于如何使用默认读取器和自定义写入器实现LibGDX Json.Serializable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆