Still one problem when parsing:
results: {"name":"New Content","language":"en","content":"","layout":
22}
java.lang.NumberFormatException: For input string: "22.0"
at java.lang.NumberFormatException.forInputString
(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:412)
at java.lang.Long.parseLong(Long.java:461)
at scala.runtime.RichString.toLong(RichString.scala:214)
def addOrUpdateContent(inContentid: String): LiftResponse = {
val obj = Content.find(By(Content.id, inContentid.toLong))
openOr
new Content
JSONParser.parse(S.params("results").first) match {
case Full(res: Map[String, String]) => {
try {
obj.name(res.getOrElse("name",
obj.name).toString)
.content(res.getOrElse("content", obj.content).toString)
.language(res.getOrElse("language", obj.language).toString)
.layout(res.getOrElse("layout",
obj.layout).toString.toLong)
.content(res.getOrElse("content", obj.content).toString)
.save
JsonResponse(JsObj("result" ->
obj.asJs))
} catch {
case e => {
Log.error("Could not save content", e)
InternalServerErrorResponse()
}
}
}
case _ => BadResponse()
}
}
any ideas? the POST content is right, the parsing is b0rkst
somewhere :s
On 17 Jul., 08:59, Jeppe Nejsum Madsen <[email protected]> wrote:
> David Pollak <[email protected]> writes:
> > You can use:
> > Box.asA[Map[String, _]](in) which will return Full(in) if in is a
> > Map[String, _] or Empty if it's not. This helps in for comprehensions.
>
> Ah, didn't know that. Very nice!
>
> /Jeppe
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---