@marius, this is slick.

However, its causing my build to error now... I get the following
stack trace when building the entire lift project:

[INFO] Compiling 22 source files to /Users/timperrett/repositories/
lift/lift-framework/lift-record/target/classes
[WARNING] /Users/timperrett/repositories/lift/lift-framework/lift-
record/src/main/scala/net/liftweb/record/MetaRecord.scala:238: error:
type mismatch;
[WARNING]  found   : net.liftweb.util.Box[net.liftweb.util.Box
[net.liftweb.record.OwnedField[BaseRecord]#MyType]]
[WARNING]  required: Iterable[?]
[WARNING] Note that implicit conversions are not applicable because
they are ambiguous:
[WARNING]  both method box2Iterable in object Box of type [T]
(net.liftweb.util.Box[T])Iterable[T]
[WARNING]  and method box2Iterable in object Box of type [T]
(net.liftweb.util.Box[T])Iterable[T]
[WARNING]  are possible conversion functions from net.liftweb.util.Box
[net.liftweb.util.Box[net.liftweb.record.OwnedField[BaseRecord]
#MyType]] to Iterable[?]
[WARNING]                field <- inst.fieldByName(k.toString)) yield
field.setFromAny(v)
[WARNING]                ^
[WARNING] one error found

On Mar 29, 1:59 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> Very nice :)
>
> On Sun, Mar 29, 2009 at 6:07 AM, Marius <marius.dan...@gmail.com> wrote:
>
> > Folks,
>
> > I just committed the Record/JSON conversion support.
>
> > Here is a simple example:
>
> > import net.liftweb.record.field._
> > import java.util._
>
> > object Main {
> >  def main(args : Array[String]) : Unit = {
>
> >    val rec = MyRecordMeta.createRecord.firstName("McLoud")
>
> >    // Change an existing record with the values from a given json
> >    val json = "{'firstName': 'Johnson', 'birthDay': 'Sun, 29 Mar 2009
> > 11:41:53 UTC', 'cars': 3, 'lastName': 'Doe'}"
> >    rec.fromJSON(json)
> >    println(rec.birthDay.value.getTime)
> >    println(rec.firstName)
> >    println(rec.cars)
>
> >    // Construct a record out of the json(opne_! is used only for
> > exemplification :)...)
> >    val rec2 = MyRecordMeta.createRecord(json).open_!
> >    println(rec2.firstName)
> >    println(rec2.birthDay.value.getTime)
> >  }
> > }
>
> > class MyRecord extends Record[MyRecord] {
> >        def meta = MyRecordMeta
>
> >        object firstName extends StringField(this, "Smith")
> >        object lastName extends StringField(this, "John")
> >        object birthDay extends DateTimeField(this, Calendar.getInstance);
> >        object cars extends IntField(this, 1);
> >  }
>
> >  object MyRecordMeta extends MyRecord with MetaRecord[MyRecord] {
> >    override def mutable_? = false
> >  }
>
> > Br's,
> > Marius
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to