Skip to content

Commit

Permalink
Merge pull request #1787 from lift/uhl_issue_1787
Browse files Browse the repository at this point in the history
Add Record and MetaRecord asJObject methods
  • Loading branch information
tuhlmann committed Apr 29, 2016
2 parents d3efb95 + cf6cd1a commit 147a801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 147a801

Please sign in to comment.