简体   繁体   中英

libgdx json serializer with a custom reader but default writer?

I'd like to achieve the opposite of this question.

I need to use a custom reader as detailed here , however, The default writer will work fine. Is there a way I can fire default writing logic from within the overridden write method?

The problem I'm having is whatever I try calls my custom writer which obviously leads to a loop and a stack overflow error.

@Override
public void write(Json json) {
    // ?? HELP!
}

@Override
public void read(Json json, JsonValue jsonData) {
    json.readFields(this, jsonData);
    checkForDodgyHighScores();
}

I belive this is what you need:

@Override
public void write(Json json) {
    json.writeFields(this);
}

If you don't want to write some object which creates loops, mark them as transient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM