#2042 Small bug in JsonOutStream with Transient field

tcolar Wed 10 Oct 2012

If you have an object where the first field is Transient there is a bug where JsonOutStream will output an extra comma, I thought this might be harmless butn the JsonInStream fails to parse it back

Say I have

class JsonTestObj
{
  @Transient Int ignore := 5  
  Bool bool1 := false
}

JsonOutSteam outputs:

{,
"bool1":false
}

See the extra comma, this fails because in JsonOutStream at line 75 it does:

if (f.isStatic || f.hasFacet(Transient#) == true) return
if (i != 0) writeChar(JsonToken.comma).writeChar('\n')

since the first field was transient and skipped (wrote nothing), the second field serialization will add that uneeded comma (because i==1 now).

brian Sun 14 Oct 2012

Thanks for bug report, I pushed a fix

Login or Signup to reply.