本文整理汇总了Scala中org.json4s.JObject类的典型用法代码示例。如果您正苦于以下问题:Scala JObject类的具体用法?Scala JObject怎么用?Scala JObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JObject类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: CreateUserRequest
//设置package包名称以及导入依赖的类
package com.biosimilarity.evaluator.importer.dtos
import org.json4s.JObject
case class CreateUserRequest(
email: String,
password: String,
jsonBlob: JObject
) extends RequestContent
case class GetUserRequest(
email: String,
password: String
) extends RequestContent
case class UpdateUserRequest(
sessionURI: String,
jsonBlob: JObject
) extends RequestContent
示例2: Interpret
//设置package包名称以及导入依赖的类
package us.grider.ghexplorer
import scalaj.http.HttpResponse
import org.json4s.{ JArray, JField, JInt, JObject, JString }
import org.json4s.native.JsonMethods.parse
object Interpret {
def apply(command: Command, http: Command => HttpResponse[String]): List[Int] = {
command match {
case ListPRs(repo) =>
val res = http(command)
val parsedBody = parse(res.body)
if (res.code >= 400) {
val errorMessage =
(parsedBody \ "message") match {
case JString(err) => err
case _ => "Error while attempting to list PRs"
}
throw new Exception(errorMessage)
} else {
parsedBody match {
case JArray(vals) => vals.collect {
case obj: JObject => obj \ "id"
}.collect {
case JInt(i) => i.toInt
}
case _ => List()
}
}
case _ => List()
}
}
}
示例3: FormElementSpec
//设置package包名称以及导入依赖的类
package com.yukimt.scrape.element
import org.specs2.mutable.Specification
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.json4s.JObject
import org.json4s.jackson.JsonMethods
import ParserMethod._
import ElementMethod._
class FormElementSpec extends Specification{
sequential
implicit val driver = new HtmlUnitDriver(true)
driver.get("http://localhost:3000/view")
val parser = new Parser(driver)
var element = (parser >> css("form")) >> asForm
"FormElement" should {
"set query string" in {
element.setQueryString(Map("a"->"b", "c"->"d"))
element >> url === "/form?a=b&c=d"
}
"submit" in {
driver.getTitle === "Express Sample Title"
element.submit
driver.getTitle === ""
}
"add form data" in {
driver.navigate.back
element = (parser >> css("form")) >> asForm
driver.getTitle === "Express Sample Title"
element.addFormData("abc", "def")
element.submit
driver.getTitle === ""
val result = JsonMethods.parse(driver.getPageSource.replaceAll("<.+>", "")).asInstanceOf[JObject].values.asInstanceOf[Map[String, String]]
result === Map("text"->"default","textarea"->"","fruit"->"a","select"->"select1","abc"->"def")
}
"set uri" in {
driver.navigate.back
element = (parser >> css("form")) >> asForm
element.setUri("/abc")
element >> url === "/abc"
}
}
}