pascallouisperez / jsonmarshaller

JsonMarshaller is a Java 1.5 library that allows marshalling and unmarshalling of JSON objects to and from entities ("Java classes").
Apache License 2.0
1 stars 0 forks source link

enum type support #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
seems that enum types are not supported

@Entity
public enum BuildTags { TEST,STABLE }

JSON:
"typology":{"id":1}

get exception during unmarshall
java.lang.IllegalStateException: java.lang.InstantiationException:
com.finantix.builder.BuildTags

Original issue reported on code.google.com by nikolas....@finantix.com on 15 Oct 2008 at 9:58

GoogleCodeExporter commented 9 years ago
it's possible use a personalized class that implements type but should be 
better a
generic support

import xxx.BuildTags;
import com.twolattes.json.types.Type;

public class EnumType implements Type<BuildTags> {

    public Class<BuildTags> getReturnedClass() {
        return BuildTags.class;
    }

    public Object marshall(BuildTags entity) {
        return entity.name();
    }

    public BuildTags unmarshall(Object object) {
        return BuildTags.valueOf((String) object);
    }
}

Original comment by nikolas....@finantix.com on 15 Oct 2008 at 9:59

GoogleCodeExporter commented 9 years ago
This feature is being implemented by William Holloway.

Original comment by pascallo...@gmail.com on 14 Dec 2008 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by pascallo...@gmail.com on 14 Dec 2008 at 6:20

GoogleCodeExporter commented 9 years ago
This has been implemented. Documentation on the way.

Original comment by pascallo...@gmail.com on 3 Jan 2009 at 2:14