Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStatic encoder codegen with Any #145
Closed
Comments
public class DemoCodegenConfig implements StaticCodegenConfig {
@Override
public void setup() {
// register custom decoder or extensions before codegen
// so that we doing codegen, we know in which case, we need to callback
Any.registerEncoders();
JsonIterator.setMode(DecodingMode.STATIC_MODE);
JsonStream.setMode(EncodingMode.STATIC_MODE);
JsonStream.setIndentionStep(2);
JsoniterSpi.registerPropertyDecoder(User.class, "score", new Decoder.IntDecoder() {
@Override
public int decodeInt(JsonIterator iter) throws IOException {
return Integer.valueOf(iter.readString());
}
});
}added Any.registerEncoders(); to fix this issue |
|
Wow, thanks! Speedy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For jsoniter
0.9.19, with this class:jsoniter codegen generates this:
The problem is
if (obj.cidMap == null) { stream.writeNull(); } else { stream.write((byte)'{', (byte)'}');. No matter what value is assigned to cid, it shows up ascid: {}in the generated json. This isn't a problem when the same code is used in dynamic mode.