json - Deserialize Java Set<Enum> using FlexJson -


im trying use flexjson deserialize json object in spring roo controller exception being thrown cannot resolve it.

daysofweek.java

public enum daysofweek {      sunday("sunday"),     monday("monday"),     tuesday("tuesday"),     wednesday("wednesday"),     thursday("thursday"),     friday("friday"),     saturday("saturday");      private final string description;      daysofweek(string description){         this.description = description;     }      public string tostring(){         return description;     } } 

calldetail.java

public class calldetail extends calendarevent {      @notnull     private string title;      @notnull     @enumerated     private callfrequency frequency;      @elementcollection(targetclass = daysofweek.class)     @enumerated     private set<daysofweek> daysofweek; } 

calldetailcontroller.java

@requestmapping(method=requestmethod.post, headers={"accept=application/json"}) public responseentity<string> createfromjson(@requestbody string json) {     calldetail calldetail = null;      try {         calldetail = calldetail.fromjsontocalldetail(json);      } catch (exception e) {         e.printstacktrace();     }     .     .     . } 

jsp

//create json object containing basic calldetail information var calldetail = {     "title" : calldetail_title.val(),     "description" : calldetail_description.val(),     "agent" : json.parse(calldetail_agent.val()),     "allday" : calldetail_isalldaycall,     "frequency" : calldetail_frequency,     "tasks" : json.parse("[" + calldetail_tasks.find('option').map(function() { return $(this).val(); }).get().join(',') + "]") }; calldetail.daysofweek = json.parse("[" + calldetail_weekdays.map(function() { return $(this).val(); }).get().join(',') + "]"); var jsondata = json.stringify(calldetail); 

json output daysofweek being rendered follows in json object being sent controller: {..."daysofweek":"[monday,tuesday,wednesday]"...}

when fromjsontocalldetail() method called throws following exception:

org.springframework.transaction.transactionsystemexception: not commit jpa transaction; nested exception javax.persistence.rollbackexception: error while committing transaction

caused by: java.lang.classcastexception: java.lang.string cannot cast java.lang.enum

can me, im trying save set of enums?


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -