• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala JValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.json4s.JValue的典型用法代码示例。如果您正苦于以下问题:Scala JValue类的具体用法?Scala JValue怎么用?Scala JValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了JValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: UserAuthSchema

//设置package包名称以及导入依赖的类
package org.goingok.data.persistence.db

import java.util.UUID

import org.goingok.data.persistence.db.postgresql.GoingOkPostgresDriver.api._
import org.goingok.data.models._
import org.json4s.JValue





class UserAuthSchema(tag:Tag) extends Table[UserAuth](tag, "user_auths") {
  def goingok_id = column[UUID]("goingok_id")
  def google_id = column[String]("google_id")
  def google_email = column[String]("google_email")
  def pkey = primaryKey("user_auth_pkey",(goingok_id))
  def * = (goingok_id,google_id,google_email) <> (UserAuth.tupled, UserAuth.unapply)
}

class UserSchema(tag:Tag) extends Table[User](tag,"users") {
  def goingok_id = column[UUID]("goingok_id")
  def pseudonym = column[String]("pseudonym")
  def research_code = column[String]("research_code")
  def research_consent = column[Boolean]("research_consent")
  def supervisor = column[Boolean]("supervisor")
  def admin = column[Boolean]("admin")
  def pkey = primaryKey("user_pkey",(goingok_id))
  def * = (goingok_id,pseudonym,research_code,research_consent,supervisor,admin) <> (User.tupled,User.unapply)
}


class MessageSchema(tag:Tag) extends Table[Message](tag,"messages") {
  def timestamp = column[String]("timestamp")
  def title = column[String]("title")
  def text = column[String]("text")
  def value = column[JValue]("value")
  def goingok_id = column[UUID]("goingok_id")
  def * = (timestamp,title,text,value,goingok_id) <> (Message.tupled,Message.unapply)
  def user = foreignKey("user_fkey", goingok_id, TableQuery[UserSchema])(_.goingok_id)
}

class ReflectionSchema(tag:Tag) extends Table[Reflection](tag,"reflections") {
  def timestamp = column[String]("timestamp")
  def point = column[Double]("point")
  def text = column[String]("text")
  def goingok_id = column[UUID]("goingok_id")
  def * = (timestamp,point,text,goingok_id) <> (Reflection.tupled,Reflection.unapply)
  def user = foreignKey("user_fkey", goingok_id, TableQuery[UserSchema])(_.goingok_id)
} 
开发者ID:GoingOK,项目名称:goingok-server,代码行数:51,代码来源:Schema.scala


示例2: UserAuth

//设置package包名称以及导入依赖的类
package org.goingok.data.models



import java.util.UUID

import org.json4s.JValue

case class UserAuth(
                   goingok_id:UUID = UUID.randomUUID(),
                   google_id:String,
                   google_email:String
                   )

case class User (
                  goingok_id:UUID,
                  pseudonym:String,
                  research_code:String,
                  research_consent:Boolean = false,
                  supervisor:Boolean = false,
                  admin:Boolean = false
                )

case class Message(
                    timestamp:String,
                    title:String,
                    text:String,
                    value:JValue,
                    goingok_id:UUID
                  )

case class Reflection(
                    timestamp:String,
                    point:Double,
                    text:String,
                    goingok_id:UUID
                  ) 
开发者ID:GoingOK,项目名称:goingok-server,代码行数:38,代码来源:DbTables.scala


示例3: DecompileLayoutSerializer

//设置package包名称以及导入依赖的类
package org.argus.amandroid.serialization

import org.argus.amandroid.core.decompile.DecompileLayout
import org.argus.jawa.core.util.{FileResourceUri, ISet}
import org.json4s.{CustomSerializer, Extraction, JValue}
import org.json4s.JsonDSL._


object DecompileLayoutSerializer extends CustomSerializer[DecompileLayout](format => (
  {
    case jv: JValue =>
      implicit val formats = format
      val outputUri  = (jv \ "outputUri").extract[FileResourceUri]
      val createFolder = (jv \ "createFolder").extract[Boolean]
      val srcFolder = (jv \ "srcFolder").extract[String]
      val libFolder = (jv \ "libFolder").extract[String]
      val createSeparateFolderForDexes = (jv \ "createSeparateFolderForDexes").extract[Boolean]
      val pkg = (jv \ "pkg").extract[String]
      val outputSrcUri = (jv \ "outputSrcUri").extract[FileResourceUri]
      val sourceFolders = (jv \ "sourceFolders").extract[ISet[String]]
      val libFolders = (jv \ "libFolders").extract[ISet[String]]
      val dependencies = (jv \ "dependencies").extract[ISet[String]]
      val thirdPartyLibraries = (jv \ "thirdPartyLibraries").extract[ISet[String]]
      val layout = DecompileLayout(outputUri, createFolder, srcFolder, libFolder, createSeparateFolderForDexes)
      layout.pkg = pkg
      layout.outputSrcUri = outputSrcUri
      layout.sourceFolders = sourceFolders
      layout.libFolders = libFolders
      layout.dependencies = dependencies
      layout.thirdPartyLibraries = thirdPartyLibraries
      layout
  },
  {
    case layout: DecompileLayout =>
      implicit val formats = format
      val outputUri: FileResourceUri = layout.outputSrcUri
      val createFolder: Boolean = layout.createFolder
      val srcFolder: String = layout.srcFolder
      val libFolder: String = layout.libFolder
      val createSeparateFolderForDexes: Boolean = layout.createSeparateFolderForDexes
      val pkg: String = layout.pkg
      val outputSrcUri: FileResourceUri = layout.outputSrcUri
      val sourceFolders: ISet[String] = layout.sourceFolders
      val libFolders: ISet[String] = layout.libFolders
      val dependencies: ISet[String] = layout.dependencies
      val thirdPartyLibraries: ISet[String] = layout.thirdPartyLibraries
      ("outputUri" -> outputUri) ~
      ("createFolder" -> createFolder) ~
      ("srcFolder" -> srcFolder) ~
      ("libFolder" -> libFolder) ~
      ("createSeparateFolderForDexes" -> createSeparateFolderForDexes) ~
      ("pkg" -> pkg) ~
      ("outputSrcUri" -> outputSrcUri) ~
      ("sourceFolders" -> Extraction.decompose(sourceFolders)) ~
      ("libFolders" -> Extraction.decompose(libFolders)) ~
      ("dependencies" -> Extraction.decompose(dependencies)) ~
      ("thirdPartyLibraries" -> Extraction.decompose(thirdPartyLibraries))
  }
)) 
开发者ID:arguslab,项目名称:Argus-SAF,代码行数:60,代码来源:DecompileLayoutSerializer.scala


示例4: ScalatraContextWrapper

//设置package包名称以及导入依赖的类
package jp.co.reraku.harmony.scalatra

import org.scalatra.{ ScalatraContext, ScalatraBase, Params, MultiParams }
import org.scalatra.util.MultiMapHeadView
import org.scalatra.servlet.{ FileUploadSupport, FileItem, FileMultiParams }
import org.scalatra.json.JsonSupport
import org.json4s.JValue

class ScalatraContextWrapper[S <: ScalatraContext](scalatraContext: S) {
  implicit def request = scalatraContext.request

  def params(implicit ev: S <:< ScalatraBase): Params =
    scalatraContext.params

  def multiParams(implicit ev: S <:< ScalatraBase): MultiParams =
    scalatraContext.multiParams

  def fileParams(implicit ev: S <:< FileUploadSupport): MultiMapHeadView[String, FileItem] =
    scalatraContext.fileParams

  def fileMultiParams(implicit ev: S <:< FileUploadSupport): FileMultiParams =
    scalatraContext.fileMultiParams

  def parsedBody(implicit ev: S <:< JsonSupport[_]): JValue =
    scalatraContext.parsedBody
} 
开发者ID:ReRaKuIMS,项目名称:harmony,代码行数:27,代码来源:ScalatraContextWrapper.scala


示例5: ThingShadowMessage

//设置package包名称以及导入依赖的类
package com.ubirch.avatar.model.rest.aws

import org.joda.time.DateTime
import org.json4s.JValue


case class ThingShadowMessage(
                               state: ThingShadowState
                             )


case class ThingShadowState(
                             inSync: Option[Boolean] = None,
                             desired: Option[JValue] = None,
                             reported: Option[JValue] = None,
                             delta: Option[JValue] = None,
                             deviceLastUpdated: Option[DateTime] = Some(DateTime.now()),
                             avatarLastUpdated: Option[DateTime] = Some(DateTime.now())
                           ) 
开发者ID:ubirch,项目名称:ubirch-avatar-service,代码行数:20,代码来源:ThingShadowMessage.scala


示例6: AvatarState

//设置package包名称以及导入依赖的类
package com.ubirch.avatar.model.rest.device

import org.joda.time.{DateTime, DateTimeZone}
import org.json4s.JValue


case class AvatarState(deviceId: String,
                       inSync: Option[Boolean] = None,
                       desired: Option[JValue] = None,
                       reported: Option[JValue] = None,
                       delta: Option[JValue] = None,
                       // update on device
                       deviceLastUpdated: Option[DateTime] = Some(DateTime.now(DateTimeZone.UTC)),
                       // update on server side
                       avatarLastUpdated: Option[DateTime] = Some(DateTime.now(DateTimeZone.UTC))
                      ) 
开发者ID:ubirch,项目名称:ubirch-avatar-service,代码行数:17,代码来源:AvatarState.scala


示例7: DeviceDraft

//设置package包名称以及导入依赖的类
package com.ubirch.avatar.model.rest.device

import org.joda.time.DateTime
import org.json4s.JValue


case class DeviceDraft(id: String,
                       name: Option[String],
                       hwType: Option[String],
                       hwId: Option[String],
                       syncState: Option[Int], // 0 = out of sync, 1 = in sync, 100 = unknown
                       tags: Option[Set[String]],
                       properties: Option[JValue],
                       subscriptions: Option[Set[String]],
                       config: Option[JValue],
                       avatar: Option[AvatarDraft],
                       created: Option[DateTime],
                       updated: Option[DateTime],
                       lastActive: Option[DateTime]
                      ) 
开发者ID:ubirch,项目名称:ubirch-avatar-service,代码行数:21,代码来源:DeviceDraft.scala


示例8: Device

//设置package包名称以及导入依赖的类
package com.ubirch.avatar.model.db.device

import java.util.UUID

import com.ubirch.avatar.config.Config
import org.joda.time.{DateTime, DateTimeZone}
import org.json4s.JValue
import org.json4s.JsonAST.{JBool, JString}


case class Device(deviceId: String,
                  groups: Set[UUID] = Set.empty,
                  deviceTypeKey: String = "unknownDeviceType",
                  deviceName: String = "unnamedDevice",
                  hwDeviceId: String = "unknownHwDeviceId",
                  hashedHwDeviceId: String = "unknownHwDeviceId",
                  tags: Set[String] = Set(),
                  deviceConfig: Option[JValue] = None,
                  deviceProperties: Option[JValue] = None,
                  subQueues: Option[Set[String]] = None,
                  pubQueues: Option[Set[String]] = Some(Set(Config.awsSqsQueueTransformerOut)),
                  avatarLastUpdated: Option[DateTime] = None,
                  deviceLastUpdated: Option[DateTime] = None,
                  updated: Option[DateTime] = None,
                  created: DateTime = DateTime.now(DateTimeZone.UTC)
                 ) {

  override def equals(obj: scala.Any): Boolean = {
    obj match {
      case dev: Device =>
        if (
          dev.deviceId == this.deviceId
        )
          true
        else
          false
      case _ => false
    }
  }

  override def hashCode(): Int = this.deviceId.hashCode

  def checkProperty(propertyKey: String): Boolean = {
    if (deviceConfig.isDefined) {
      (deviceProperties.get.camelizeKeys \ propertyKey).equals(JString("true")) ||
        (deviceProperties.get.camelizeKeys \ propertyKey).equals(JBool(true))
    }
    else
      false
  }
} 
开发者ID:ubirch,项目名称:ubirch-avatar-service,代码行数:52,代码来源:Device.scala


示例9: InterceptionController

//设置package包名称以及导入依赖的类
package com.innoq.integration

import akka.actor.{ActorRef, ActorSystem}
import org.json4s.{DefaultFormats, Formats, JValue}
import org.scalatra.json.JacksonJsonSupport
import org.scalatra.{FutureSupport, Ok, ScalatraServlet}
import org.slf4j.LoggerFactory

class InterceptionController(actorSystem: ActorSystem, interceptionHandler: ActorRef) extends ScalatraServlet with JacksonJsonSupport with FutureSupport {

  protected implicit val jsonFormats: Formats = DefaultFormats

  protected override def transformRequestBody(body: JValue): JValue = body.camelizeKeys

  protected override def transformResponseBody(body: JValue): JValue = body.underscoreKeys

  protected implicit def executor = scala.concurrent.ExecutionContext.Implicits.global

  protected val log = LoggerFactory.getLogger(classOf[InterceptionController])

  log.info("Starting interception controller")

  before() {
    contentType = formats("json")
  }

  get("/*") {
    Ok
  }

  put("/") {
    val interception = parsedBody.extract[Interception]
    log.info(s"Setting interception: $interception")
    interceptionHandler ! SetInterception(interception)
    Ok
  }

  post("/") {
    val interception = parsedBody.extract[Interception]
    log.info(s"Adding interception: $interception")
    interceptionHandler ! AddInterception(interception)
    Ok
  }

  delete("/*") {
    log.info(s"Deleting interceptions")
    interceptionHandler ! DeleteInterceptions()
    Ok
  }
} 
开发者ID:mputz86,项目名称:testing-with-logging,代码行数:51,代码来源:InterceptionController.scala


示例10: UpdateSerializer

//设置package包名称以及导入依赖的类
package ru.finagram.api.json

import org.json4s.JsonAST.JObject
import org.json4s.JsonDSL._
import org.json4s.{ DefaultFormats, Extraction, Formats, JValue, Serializer, TypeInfo }
import ru.finagram.api.{ CallbackQueryUpdate, MessageUpdate, Update }
import ru.finagram.!!!

object UpdateSerializer extends Serializer[Update] {

  private val UpdateClass = classOf[Update]

  override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Update] = {
    case (TypeInfo(UpdateClass, _), json: JObject) =>
      json.values match {
        case v if v.contains("message") =>
          json.extract[MessageUpdate]
        case v if v.contains("callbackQuery") =>
          json.extract[CallbackQueryUpdate]
        case v => !!!(s"Not implemented deserialization for $v")
      }
  }

  override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
    case u: MessageUpdate =>
      ("update_id" -> u.updateId) ~~ ("message" -> json(u.message))
    case u: CallbackQueryUpdate =>
      ("update_id" -> u.updateId) ~~ ("callback_query" -> json(u.callbackQuery))
  }

  private def  json(obj: AnyRef): JValue = {
    implicit val formats = DefaultFormats
    Extraction.decompose(obj).snakizeKeys
  }
} 
开发者ID:finagram,项目名称:finagram,代码行数:36,代码来源:UpdateSerializer.scala


示例11: MessageSerializer

//设置package包名称以及导入依赖的类
package ru.finagram.api.json

import org.json4s.JsonAST._
import org.json4s.JsonDSL._
import org.json4s.{ DefaultFormats, Extraction, Formats, JValue, Serializer, TypeInfo }
import ru.finagram.api._
import ru.finagram.!!!

object MessageSerializer extends Serializer[Message] {

  private val MessageClass = classOf[Message]

  override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Message] = {
    case (TypeInfo(MessageClass, _), json: JObject) =>
      json.values match {
        case v if v.contains("video") =>
          json.extract[VideoMessage]
        case v if v.contains("voice") =>
          json.extract[VoiceMessage]
        case v if v.contains("photo") =>
          json.extract[PhotoMessage]
        case v if v.contains("location") =>
          json.extract[LocationMessage]
        case v if v.contains("document") =>
          json.extract[DocumentMessage]
        case v if v.contains("sticker") =>
          json.extract[StickerMessage]
        case v if v.contains("text") =>
          json.extract[TextMessage]
        case v => !!!(s"Not implement deserialization for $v")
      }
  }

  override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
    case m: VideoMessage =>
      JMessage(m) ~~ ("video" -> json(m.video))
    case m: VoiceMessage =>
      JMessage(m) ~~ ("voice" -> json(m.voice))
    case m: PhotoMessage =>
      JMessage(m) ~~ ("photo" -> json(m.photo))
    case m: LocationMessage =>
      JMessage(m) ~~ ("location" -> json(m.location))
    case m: DocumentMessage =>
      JMessage(m) ~~ ("document" -> json(m.document))
    case m: StickerMessage =>
      JMessage(m) ~~ ("sticker" -> json(m.sticker))
    case m: TextMessage =>
      JMessage(m) ~~ ("text" -> m.text)
  }

  private def JMessage(m: Message): JObject = {
    val jobject = ("messageId" -> m.messageId) ~ ("chat" -> json(m.chat)) ~ ("date" -> m.date)
    if (m.from.isEmpty) jobject else jobject ~~ ("from", json(m.from.get))
  }

  private def  json(obj: AnyRef): JValue = {
    implicit val formats = DefaultFormats
    Extraction.decompose(obj)
  }
} 
开发者ID:finagram,项目名称:finagram,代码行数:61,代码来源:MessageSerializer.scala


示例12: KeyboardMarkupSerializer

//设置package包名称以及导入依赖的类
package ru.finagram.api.json

import org.json4s.JsonAST.JObject
import org.json4s.{ Formats, JValue, Serializer, TypeInfo }
import ru.finagram.api.{ InlineKeyboardMarkup, KeyboardMarkup, ReplyKeyboardMarkup }

object KeyboardMarkupSerializer extends Serializer[KeyboardMarkup] {

  private val KeyboardMarkupClass = classOf[KeyboardMarkup]

  override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), KeyboardMarkup] = {
    case (TypeInfo(KeyboardMarkupClass, _), json: JObject) =>
      json.values match {
        case v if v.contains("keyboard") =>
          json.extract[ReplyKeyboardMarkup]
        case v if v.contains("inline_keyboard") =>
          json.extract[InlineKeyboardMarkup]
      }
  }

  override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = PartialFunction.empty
} 
开发者ID:finagram,项目名称:finagram,代码行数:23,代码来源:KeyboardMarkupSerializer.scala


示例13: JsonSituation

//设置package包名称以及导入依赖的类
package org.cddcore.json

import org.cddcore.structure.{PathRootAndSteps, Situation, Structure}
import org.json4s.jackson.{JsonMethods, Serialization}
import org.json4s.{DefaultFormats, JValue}

/** To use this you probably need to
import JsonSituation._
  */

class JsonSituation (implicit structure: Structure[JValue]) extends Situation[JValue] {
  def parse(s: String)(implicit formats: DefaultFormats = DefaultFormats) = root(JsonMethods.parse(s))


}

object JsonSituation {

  implicit object JsonStructure extends Structure[JValue] {

    override def findResult(pathRootAndSteps: PathRootAndSteps[JValue]): Iterable[JValue] = {
      import pathRootAndSteps._
      List(steps.foldLeft(root: JValue) { case (acc, step) =>
        step.linked match {
          case true => acc \ step.element
          case false => acc \\ step.element
        }
      })
    }

    override def structureTitle: String = "json"

    override def sToString(s: JValue): String = {
      implicit val formats = DefaultFormats
      Serialization.writePretty(s)
    }
  }

} 
开发者ID:phil-rice,项目名称:CddCore2,代码行数:40,代码来源:Json.scala


示例14: JsonSpec

//设置package包名称以及导入依赖的类
package org.cddcore.json

import org.cddcore.structure.PathRoot
import org.cddcore.utilities._
import org.json4s.JValue

class JsonSpec extends CddSpec {

  import JsonSituation._

  object JsonForTest extends JsonSituation {
    @DontDisplay
    val json: PathRoot[JValue] = parse("""{"a": 1, "b": 2, "c": {"d": 1}}""")
    val aAsString = json \ "a" \ string
    val aAsInt = json \ "a" \ int
    val b = json \ "b" \ int
    val cd = json \ "c" \ "d" \ int
    @Display
    val someVariable = "someValue"
    val someHiddenVariable = "someHiddenValue"
  }

  "Json structures" should "allow easy access to data in the structure" in {
    JsonForTest.aAsInt() shouldBe 1
    JsonForTest.aAsString() shouldBe "1"
    JsonForTest.b() shouldBe 2
    JsonForTest.cd() shouldBe 1
  }

  it should "have a nice summary display string" in {
    val dp = DisplayProcessor()
    val summary: String = dp.summary(JsonForTest)
    summary shouldBe "JsonForTest$(someVariable -> someValue)"
  }
  it should "have a nice detailed display string" in {
    val dp = DisplayProcessor()
    Strings.splitLines(dp.detailed(JsonForTest)) shouldBe Strings.splitLines(
      """JsonForTest$(
        |  aAsString -> 1
        |  aAsInt -> 1
        |  b -> 2
        |  cd -> 1
        |  someVariable -> someValue
        |)""".stripMargin)
  }
} 
开发者ID:phil-rice,项目名称:CddCore2,代码行数:47,代码来源:JsonSpec.scala


示例15: AddNew

//设置package包名称以及导入依赖的类
package codes.bytes.quaich.samples.plain

import java.io.OutputStream

import akka.typed.scaladsl.Actor
import akka.typed.scaladsl.AskPattern._
import akka.typed.{ActorRef, ActorSystem, Behavior}
import akka.util.Timeout
import codes.bytes.quaich.api.LambdaContext
import codes.bytes.quaich.api.direct.{DirectLambda, DirectLambdaHandler}
import org.json4s.JValue
import org.json4s.JsonAST.JString

import scala.concurrent.{Await, Future}
import scala.concurrent.duration._

sealed trait NameMsg

final case class AddNew(lang: String, replyTo: ActorRef[Array[String]]) extends NameMsg

@DirectLambda
class PlainLambda extends DirectLambdaHandler {
  implicit val timeout = Timeout(1.second)

  val namedBehavior: Behavior[NameMsg] = Actor.mutable[NameMsg](ctx => new NameActor)

  val system: ActorSystem[NameMsg] = ActorSystem("hello", namedBehavior)

  override protected def handleEvent(json: JValue, output: OutputStream)(implicit ctx: LambdaContext) {
    json match {
      case JString(lang) =>
        implicit val scheduler = system.scheduler
        val results: Future[Array[String]] = system ? { ref => AddNew(lang, ref) }
        writeJson (output, Await.result (results, timeout.duration) )

      case other =>
        ctx.log.error(s"Uncreckognized JSON format")
    }
  }
}

class NameActor extends Actor.MutableBehavior[NameMsg] {

  private var names: List[String] = Nil

  override def onMessage(msg: NameMsg): Behavior[NameMsg] = {
    msg match {
      case AddNew(lang, replyTo) =>
        names = lang :: names
        replyTo ! names.toArray
    }

    this
  }
} 
开发者ID:pdolega,项目名称:quaich-other-samples,代码行数:56,代码来源:AkkaLambda.scala


示例16: CloudFormationCustomResourceRequest

//设置package包名称以及导入依赖的类
package com.dwolla.lambda.cloudformation

import org.json4s.JValue

case class CloudFormationCustomResourceRequest(RequestType: String,
                                               ResponseURL: String,
                                               StackId: String,
                                               RequestId: String,
                                               ResourceType: String,
                                               LogicalResourceId: String,
                                               PhysicalResourceId: Option[String],
                                               ResourceProperties: Option[Map[String, JValue]],
                                               OldResourceProperties: Option[Map[String, JValue]])

case class CloudFormationCustomResourceResponse(Status: String,
                                                Reason: Option[String],
                                                PhysicalResourceId: Option[String],
                                                StackId: String,
                                                RequestId: String,
                                                LogicalResourceId: String,
                                                Data: Map[String, AnyRef] = Map.empty[String, AnyRef])

object MissingResourceProperties extends RuntimeException 
开发者ID:Dwolla,项目名称:scala-cloudformation-custom-resource,代码行数:24,代码来源:model.scala


示例17: FieldNamesMappingUtils

//设置package包名称以及导入依赖的类
package com.datawizards.sparklocal.impl.scala.dataset.io

import com.datawizards.dmg.dialects.Dialect
import com.datawizards.dmg.metadata.MetaDataExtractor
import com.datawizards.sparklocal.dataset.io.JSONDialect
import org.json4s.JValue
import org.json4s.JsonAST.JObject

import scala.reflect.runtime.universe.TypeTag


object FieldNamesMappingUtils {
  def constructFieldNameMapping[T: TypeTag](dialect: Dialect, fromOriginal: Boolean=true): Map[String, String] = {
    val classTypeMetaData = MetaDataExtractor.extractClassMetaDataForDialect[T](dialect)
    classTypeMetaData
      .fields
      .map{ f =>
        if(fromOriginal) f.originalFieldName -> f.fieldName
        else f.fieldName -> f.originalFieldName
      }
      .toMap
  }

  def changeJsonObjectFieldNames[T: TypeTag](value: JValue, fromOriginal: Boolean): JValue = value match {
    case JObject(fields) =>
      val fieldNameMapping = FieldNamesMappingUtils.constructFieldNameMapping[T](JSONDialect, fromOriginal)
      JObject(
        fields.map{case (fieldName, fieldValue) =>
          (fieldNameMapping.getOrElse(fieldName, fieldName), fieldValue)
        }
      )
    case other => other
  }
} 
开发者ID:piotr-kalanski,项目名称:spark-local,代码行数:35,代码来源:FieldNamesMappingUtils.scala


示例18: CouchDbReceiverMessage

//设置package包名称以及导入依赖的类
package pl.edu.agh.iet.akka_tracing.couchdb.model

import java.util.UUID

import org.json4s.JValue
import pl.edu.agh.iet.akka_tracing.model.MessagesRelation

case class CouchDbReceiverMessage(_id: String,
                                  receiver: String,
                                  _rev: Option[String] = None)
  extends Document

case class CouchDbSenderMessage(_id: String,
                                sender: String,
                                contents: Option[JValue],
                                _rev: Option[String] = None)
  extends Document

case class CouchDbMessagesRelation(_id: String,
                                   id1: String,
                                   id2: String,
                                   _rev: Option[String] = None)
  extends Document {

  def toMessagesRelation: MessagesRelation =
    MessagesRelation(UUID.fromString(id1), UUID.fromString(id2))
} 
开发者ID:akka-tracing-tool,项目名称:akka-tracing-couchdb-collector,代码行数:28,代码来源:CouchDbModels.scala


示例19: CborSerializer

//设置package包名称以及导入依赖的类
package io.mediachain.util

import io.mediachain.core.TranslationError.{ConversionToJsonFailed, InvalidFormat}
import io.mediachain.Types.Signable

object CborSerializer {
  import cats.data.Xor
  import io.mediachain.Types.Hashable
  import org.json4s.{MappingException, DefaultFormats, Extraction, Formats}
  import org.json4s.JValue
  import io.mediachain.util.{CborMethods => Cbor}

  def bytesForJsonValue(json: JValue): Array[Byte] =
    Cbor.bytes(Cbor.render(json))

  def sha1StringForJsonValue(json: JValue): String =
    Cbor.sha1String(Cbor.render(json))


  def bytesForJsonText(jsonString: String): Xor[InvalidFormat, Array[Byte]] =
    JsonUtils.parseJsonString(jsonString)
      .map(bytesForJsonValue)

  def sha1StringForJsonText(jsonString: String): Xor[InvalidFormat, String] =
    JsonUtils.parseJsonString(jsonString)
      .map(sha1StringForJsonValue)

  def bytesForValue[A <: AnyRef](a: A)(implicit formats: Formats = DefaultFormats)
  : Xor[ConversionToJsonFailed, Array[Byte]] = {
    val asJValue = Xor.catchOnly[MappingException] {
      Extraction.decompose(a)(formats)
    }.leftMap(e => ConversionToJsonFailed(e.getMessage))

    asJValue.map(bytesForJsonValue)
  }

  def bytesForHashable[H <: Hashable](h: H): Array[Byte] = {
    bytesForJsonValue(JsonUtils.jsonObjectForHashable(h))
  }

  def bytesForSignable[S <: Signable](s: S): Array[Byte] = {
    bytesForJsonValue(JsonUtils.jsonObjectForSignable(s))
  }
} 
开发者ID:mediachain,项目名称:L-SPACE,代码行数:45,代码来源:CborSerializer.scala


示例20: KeyNotFound

//设置package包名称以及导入依赖的类
package cddamod

import org.json4s.JValue
import org.json4s.native.Printer.pretty

sealed trait Error
case class KeyNotFound(key: String, at: JValue) extends Error {
  override def toString = "KeyNotFound[\""+key+"\"]\n" + pretty(MorePretty prend at)
}
case class UnexpectedValueType(at: JValue) extends Error {
  override def toString = "UnexpectedValueType\n" + pretty(MorePretty prend at)
}
case class ExpectedValueType(str: String, actual: JValue) extends Error
case class UnmatchedValueType(required: String, actual: JValue) extends Error {
  override def toString = 
    "UnexpectedValueType\n require:"+ required + "\n actual:"+ pretty(MorePretty prend actual)
}
case class ParseError(failureString: String, atWord: String) extends Error


package importerror {
trait ImportError extends Error
object NoBrowser extends ImportError
object RefNotFound extends ImportError
object MultiRef extends ImportError
object NoBindIdent extends ImportError
object Reserved extends ImportError
case class FormatError(opt: String) extends ImportError
case class NotFoundIdent(ident: String) extends ImportError
case class NoSupport(code: String) extends ImportError
}


package prompterror {
trait PromptError extends Error
object NoDictionary extends PromptError { override def toString = "NoDictionary" }
object NoDictionaryOrder extends PromptError { override def toString = "NoDictionaryOrder" }
object NoBrowser extends PromptError { override def toString = "NoBrowser" }
object InvalidQueryFormat extends PromptError {override def toString = "InvalidQueryFormat" }
object NoSuchCommand extends PromptError { override def toString = "NoSuchCommand" }
} 
开发者ID:YueKaburagi,项目名称:cdda-modding-helper,代码行数:42,代码来源:Error.scala



注:本文中的org.json4s.JValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala HttpServletRequest类代码示例发布时间:2022-05-23
下一篇:
Scala DataOutputStream类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap