@JSON on fields

Help
Mike 2
2010-09-28
2013-03-19
  • Mike 2

    Mike 2 - 2010-09-28

    Hi, the javadoc notes on @JSON say that the @JSON annotation may be placed on methods or fields, but field placement doesn't seem to be enabled:

    http://flexjson.sourceforge.net/javadoc/index.html?flexjson/JSON.html

    Another question re: the @JSON annotation: If a field is marked @JSON(include=true), does that mean that all other fields are automatically excluded?

     
  • Charlie Hubbard

    Charlie Hubbard - 2010-09-28

    You are right this is an issue in 2.0 that will be fixed in 2.1.  We're working through some minor bugs with 2.1 at the moment that is holding up releasing 2.1.  Once we have those fixed expect 2.1 out soon.  This release will include several bug fixes along with some new features: Android support, deserialize into an existing object, and support for using a java.io.Reader/java.io.Writer instead of a String for serialization and deserialization.  (technically using a java.io.Writer for serialization is already supported in 2.0).

    The work around is to put the @JSON on the getter method in your object.

    Charlie

     
  • Charlie Hubbard

    Charlie Hubbard - 2010-09-28

    …does that mean that all other fields are automatically excluded?

    No putting the annotation on a field doesn't mean anything for the other fields in the object.  Typically, the @JSON annotation only makes sense for always excluding fields (i.e. @JSON(include=false) ).  However, there is one use case for including fields with the @JSON annotation and that is when you have field that is Collection/Array  that you always want to serialize.

    Charlie

     
  • Mike 2

    Mike 2 - 2010-09-28

    Ah…thanks so much! Will keep en eye out for 2.1.

     
  • Håkon Lorentzen

    This wasn't fixed in 2.1. Any reason for that?

     
  • Anonymous - 2012-02-27

    Ping … This would be great to have fixed soon.

     
  • Anonymous - 2013-01-10

    Sigh, so it's been a year and a half and it's still v2.1 and still not fixed? Can you please just add ElementType.FIELD? Maybe in a v2.1.1?

     
  • Charlie Hubbard

    Charlie Hubbard - 2013-01-10

    Yes.  We got caught up trying to reproduce a bug that wasn't easily reproducible, and that delayed the release.  I think at this point it's safe to say we can release the code.  I'll release it ASAP.  Sorry for the delay.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks