For jsoniter 0.9.19, with this class:
public class EmailSelf {
public String subject;
public String body;
public Any cidMap;
}
jsoniter codegen generates this:
public class EmailSelf implements com.jsoniter.spi.Encoder {
public void encode(java.lang.Object obj, com.jsoniter.output.JsonStream stream) throws java.io.IOException {
if (obj == null) { stream.writeNull(); return; }
stream.writeRaw("{\"subject\":", 11);
encode_((java2ts.EmailSelf)obj, stream);
stream.write((byte)'}');
}
public static void encode_(java2ts.EmailSelf obj, com.jsoniter.output.JsonStream stream) throws java.io.IOException {
if (obj.subject == null) { stream.writeNull(); } else {
stream.writeVal((java.lang.String)obj.subject);
}
stream.writeRaw(",\"body\":", 8);
if (obj.body == null) { stream.writeNull(); } else {
stream.writeVal((java.lang.String)obj.body);
}
stream.writeRaw(",\"cidMap\":", 10);
if (obj.cidMap == null) { stream.writeNull(); } else {
stream.write((byte)'{', (byte)'}');
jsoniter_codegen.cfg9223372036100299902.encoder.com.jsoniter.any.Any.encode_((com.jsoniter.any.Any)obj.cidMap, stream);
}
}
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 as cid: {} in the generated json. This isn't a problem when the same code is used in dynamic mode.
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.