diff --git a/persistence/record/src/main/scala/net/liftweb/record/MetaRecord.scala b/persistence/record/src/main/scala/net/liftweb/record/MetaRecord.scala index 41f4d75368..f5168ed6fd 100644 --- a/persistence/record/src/main/scala/net/liftweb/record/MetaRecord.scala +++ b/persistence/record/src/main/scala/net/liftweb/record/MetaRecord.scala @@ -246,6 +246,11 @@ trait MetaRecord[BaseRecord <: Record[BaseRecord]] { /** Encode a record instance into a JValue */ def asJValue(rec: BaseRecord): JValue = { + asJObject(rec) + } + + /** Encode a record instance into a JObject */ + def asJObject(rec: BaseRecord): JObject = { JObject(fields(rec).map(f => JField(f.name, f.asJValue))) } diff --git a/persistence/record/src/main/scala/net/liftweb/record/Record.scala b/persistence/record/src/main/scala/net/liftweb/record/Record.scala index 1d3f910516..cf79de63d0 100644 --- a/persistence/record/src/main/scala/net/liftweb/record/Record.scala +++ b/persistence/record/src/main/scala/net/liftweb/record/Record.scala @@ -90,9 +90,12 @@ trait Record[MyType <: Record[MyType]] extends FieldContainer { */ def asJsExp: JsExp = meta.asJsExp(this) - /** Encode this record instance as a JObject */ + /** Encode this record instance as a JValue */ def asJValue: JValue = meta.asJValue(this) + /** Encode this record instance as a JObject */ + def asJObject: JObject = meta.asJObject(this) + /** Set the fields of this record from the given JValue */ def setFieldsFromJValue(jvalue: JValue): Box[Unit] = meta.setFieldsFromJValue(this, jvalue)