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