lifter
unread,Mar 29, 2011, 8:23:01 PM3/29/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Lift
Im getting a strange exception with the JSON extractor,
"net.liftweb.json.MappingException: No usable value for $outer"... has
anyone seen this before / can point me in the right direction to fix
this?
Here's some context: I'm writing a program that uses an API. The API
spits out JSON in the form of:
{"status":"ok","error":"","invited_users":[],"folder_id":
63785069,"folder_name":"rrrrrrrrrrrrr"}
Basically Im trying to determine whether or not I got a successful
message. If it doesnt conform to that pattern, something bad happened
and I dont really care.
def isGood(response: String): Boolean =
{
try
{
case class FolderCreateSuccessResponse(status: String, error:
String, invited_users: List[Long], folder_id: Long, folder_name:
String)
implicit val formats = DefaultFormats //need this line or wont
compile, idk why
val resp : FolderCreateSuccessResponse =
parse(response).extract[FolderCreateSuccessResponse]
return resp.status == "ok"
}
catch {
case me : MappingException => {
// do nothing... i dont care
}
}
return false
}
For this given input, I get the following stack trace
Input String: {"status":"ok","error":"","invited_users":[],"folder_id":
6926246,"folder_name":"new folder"}
Trace:
net.liftweb.json.MappingException: No usable value for $outer
No usable value for myInfo
No usable value for pkg
Did not find value which can be converted into java.lang.String
at net.liftweb.json.Meta$.fail(Meta.scala:128)
at net.liftweb.json.Extraction$.mkValue$1(Extraction.scala:275)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:242)
at net.liftweb.json.Extraction$$anonfun$4.apply(Extraction.scala:194)
at net.liftweb.json.Extraction$$anonfun$4.apply(Extraction.scala:194)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map
$1.apply(TraversableLike.scala:206)
at scala.collection.LinearSeqOptimized
$class.foreach(LinearSeqOptimized.scala:61)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:
206)
at scala.collection.immutable.List.map(List.scala:45)
at net.liftweb.json.Extraction$.instantiate$1(Extraction.scala:194)
at net.liftweb.json.Extraction$.newInstance$1(Extraction.scala:222)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:240)
at net.liftweb.json.Extraction$.extract(Extraction.scala:284)
at net.liftweb.json.Extraction$.extract0(Extraction.scala:172)
at net.liftweb.json.Extraction$.extract(Extraction.scala:40)
at net.liftweb.json.JsonAST$JValue.extract(JsonAST.scala:288)
a weird thing is the myInfo and pkg variables are listed there...
myInfo is an object and has a property named pkg, but they should be
unrelated