Thanks for your reply. Actually I was trying to build an exception I
am receiving in our product.

case class X(yy:Y)
case class Y(ss:String)

  def from(in:String):X={
    implicit val formats = net.liftweb.json.DefaultFormats
    import net.liftweb.json.JsonAST._
    import net.liftweb.json.Extraction._
    import net.liftweb.json.Printer._
    net.liftweb.json.Serialization.read[X](in)
  }
  def to(in:X):String={
    implicit val formats = net.liftweb.json.DefaultFormats
    import net.liftweb.json.JsonAST._
    import net.liftweb.json.Extraction._
    import net.liftweb.json.Printer._
    compact(render(decompose(in)))
  }

val sample = new X(null)
val sample2=from(to(sample))

and I am getting,
     net.liftweb.json.MappingException: Did not find value which can
be converted into java.lang.String
        at net.liftweb.json.Meta$.fail(Meta.scala:99)
        at net.liftweb.json.Extraction$.convert(Extraction.scala:280)
        at net.liftweb.json.Extraction$.build$1(Extraction.scala:216)
        at net.liftweb.json.Extraction$$anonfun$newInstance
$1$1.apply(Extraction.scala:199)
        at net.liftweb.json.Extraction$$anonfun$newInstance
$1$1.apply(Extraction.scala:199)
        at scala.List.map(List.scala:812)

I appreciate your comment,

Thanks,
-A

On Feb 20, 12:10 am, Joni Freeman <[email protected]> wrote:
> Is X perhaps an inner class? Inner class has an implicit reference to
> outer instance. Serializing those is not supported.
>
> If so, please move definition of X outside of class.
>
> Cheers Joni
>
> On Feb 20, 12:16 am, Ali <[email protected]> wrote:
>
> > Hi,
> >  I am wondering, could you please let me know what is wrong in the
> > following code:
>
> > case class X(vv:String)
> > val sample = new X("A")
>
> >       implicit val formats = net.liftweb.json.DefaultFormats
> >       import net.liftweb.json.JsonAST._
> >       import net.liftweb.json.Extraction._
> >       import net.liftweb.json.Printer._
>
> >       def from(in:String):X=net.liftweb.json.Serialization.read[X](in)
> >       def to(in:X):String=compact(render(decompose(in)))
>
> >       val sample2=from(to(sample))
> >       sample2 must_== sample
>
> > I am getting  java.util.NoSuchElementException: key not found: $outer
>
> > Thanks,
> > -A

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to