Hi, I just updated to the latest lift-json snapshot and tried to serialize one of my case classes: The output starts with:
{ "bitmap$0":0, "sell_exp":null, "buy_exp":null, "x$3":null, "sell_exp_str":null, "buy_exp_str":null, "x$2":null, "sell_vars":null, "buy_vars":null, "x$1":null, For your information, things like buy_exp, buy_vars,... are declared as lazy val inside the body of the case class. I have two questions: - Is it possible to configure lift-json so It would not serialize internal variables ? case class X(a:Int) {lazy val y = a} - Is it possible to generate a clean json output without x$0 or bitmap $0,... entries ? Thanks, -A On Feb 14, 5:32 pm, Joni Freeman <freeman.j...@gmail.com> wrote: > Hi, > > I just added Array support and fixed the bug 341. It is now waiting on > review board for others to comment. You can checkout branch > 'joni_issue_341' if you want to try it immediately. > > This test case now passes (Please note the verbose assertions in > second test case. Those are needed because scala.Array's equals is > reference comparison, Array(1, 2) == Array(1, 2) -> false): > > http://github.com/dpp/liftweb/blob/joni_issue_341/framework/lift-base... > > Cheers Joni > > On Feb 11, 12:09 pm, Ali <saleh...@gmail.com> wrote: > > > Thanks guys, Actually my problem is still there, It looks like > > lift-jsondoesn't support scala-arrays. > > > case class Plan( leftOperand:Option[Action], > > operator:Option[String], > > rightOperand:Option[Action]) > > > case class Game(buy:Map[String,Plan]) > > > case class Action( > > functionName:String, > > symbol:String, > > inParams: Array[Number] , > > subOperand : Option[Action]) > > > val game = new Game(Map("a"->new Plan(Some(new > > Action("f1","s",Array(),None)),Some("A"),Some(new > > Action("f1","s",Array(0,1,2),None))))) > > implicit val format = > > Serialization.formats(ShortTypeHints(List(classOf[Plan], > > classOf[Action], classOf[Game]))) > > println(Serialization.write(game)) > > > The output is: > > > {"jsonClass":"Game","buy":{"a":{"jsonClass":"Plan","rightOperand": > > {"jsonClass":"Action","symbol":"s","functionName":"f1"},"operator":"A","leftOperand": > > {"jsonClass":"Action","symbol":"s","functionName":"f1"}}}} > > > which is not correct (missing the inParams field from the action > > class). > > > I appreciate your comment, > > > Cheers, > > -A > > On Feb 11, 8:44 am, Joni Freeman <freeman.j...@gmail.com> wrote: > > > > Hi, > > > > Type hints should not be needed in this case since the Map is not used > > > in a polymorphic way. But the work-around Justin showed should work. > > > Actually it seems that it is enough to put type info just to Action to > > > make serialization work: > > > > implicit val format = > > > Serialization.formats(ShortTypeHints(List(classOf[Action])) > > > > Anyway, I added a ticket for this > > > defect:http://www.assembla.com/spaces/liftweb/tickets/341-Type-hints-are-nee... > > > > Cheers Joni > > > > On Feb 10, 7:49 pm, Justin Reardon <justin.rear...@gmail.com> wrote: > > > > > Sometimes the serialization code needs a helping hand, using: > > > > > implicit val format = > > > > Serialization.formats(ShortTypeHints(List(classOf[Plan], > > > > classOf[Action], classOf[Game]))) > > > > > instead of the defaults makes it work here. > > > > > Cheers, > > > > Justin Reardon > > > > > On 2010-02-10, at 11:42 , Ali wrote: > > > > > > Dear All, > > > > > I am wondering would you please tell me how can I uselift-json(2.0 > > > > > snapshots) to serialize and deserialize the following scala case > > > > > classes. > > > > > > case class Plan( plan:Option[Action] ) > > > > > case class Game( game:Map[String,Plan]) > > > > > case class Action(id:Int, subAction : Option[Action]) > > > > > > val game = new Game(Map("a"->new Plan(new Some(new Action(1,None))))) > > > > > implicit val formats = net.liftweb.json.DefaultFormats > > > > > > game must beEqualTo( Serialization.read[Game] > > > > > (Serialization.write(game))) > > > > > > Test fails. > > > > > > Cheers, > > > > > -A > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > Groups "Lift" group. > > > > > To post to this group, send email to lift...@googlegroups.com. > > > > > To unsubscribe from this group, send email to > > > > > liftweb+unsubscr...@googlegroups.com. > > > > > For more options, visit this group > > > > > athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.