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

Scala Format类代码示例

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

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



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

示例1: PlayJsonSnapshotMatcherSpec

//设置package包名称以及导入依赖的类
package com.commodityvectors.snapshotmatchers.playJson

import java.io.File

import com.commodityvectors.snapshotmatchers.{SnapshotMatcher, SnapshotSerializer}
import org.apache.commons.io.FileUtils
import org.scalatest.{BeforeAndAfterEach, Matchers, fixture}
import play.api.libs.json.{Format, JsValue, Json}

import scala.util.Try

class PlayJsonSnapshotMatcherSpec extends fixture.WordSpec with Matchers with SnapshotMatcher with PlayJsonSnapshotMatcher with BeforeAndAfterEach {
  case class Test(value: Int)
  implicit lazy val jsonFormat: Format[Test] = Json.format[Test]

  val snapshotFolder: String = "scalatest-snapshot-matcher-play-json/src/test/__snapshots__"
  val currentSpecPath: String = s"$snapshotFolder/com/commodityvectors/snapshotmatchers/playJson/PlayJsonSnapshotMatcherSpec"

  override def afterEach(): Unit = {
    Try(FileUtils.deleteDirectory(new File(snapshotFolder)))
  }

  "PlayJsonSnapshotMatcherSpec" should {
    "pretty print json" in { implicit test =>
      val instance = Test(1)
      SnapshotSerializer.serialize(Json.toJson(instance)) shouldEqual
        s"""{
           |  "value" : 1
           |}""".stripMargin
    }

    "generate json snapshot file" in { implicit test =>
      val instance = Test(1)
      Json.toJson(instance) should matchSnapshot[JsValue]("customId")
      FileUtils.readFileToString(
        new File(s"$currentSpecPath/customId.snap")
      ) shouldEqual
        s"""{
           |  "value" : 1
           |}""".stripMargin
    }

    "allow deserialization" in { implicit test =>
      val instance = Test(1)
      Json.toJson(instance) should matchSnapshot[JsValue]("anotherId")
      "anotherId" should deserializeAs(instance)
    }
  }
} 
开发者ID:commodityvectors,项目名称:scalatest-snapshot-matchers,代码行数:50,代码来源:PlayJsonSnapshotMatcherSpec.scala


示例2: ContentType

//设置package包名称以及导入依赖的类
package io.soheila.cms.entities

import io.soheila.commons.formats.EnumFormat
import play.api.libs.json.Format

object ContentType extends Enumeration {
  type ContentType = Value

  val Html = Value("Html")
  val Text = Value("Text")
  val Markup = Value("Markup")
  val Wysiwyg = Value("Wysiwyg")
}

case class Content(rawText: String, text: String, contentType: ContentType.Value)

object Content {
  import play.api.libs.json.Json

  implicit val contentTypeFormat: Format[ContentType.Value] = EnumFormat.enumFormat(ContentType)
  implicit val jsonFormat = Json.format[Content]
} 
开发者ID:esfand-r,项目名称:soheila-cm,代码行数:23,代码来源:Content.scala


示例3: UnmarshallingDDirectivesSpec

//设置package包名称以及导入依赖的类
package akka.http.documenteddsl

import java.time.LocalDate

import akka.http.documenteddsl.directives.UnmarshallingDDirectives._
import akka.http.documenteddsl.documentation.OutDocumentation._
import akka.http.documenteddsl.documentation.{JsonSchema, OutDocumentation, RouteDocumentation}
import akka.http.scaladsl.model.{ContentTypes, StatusCodes}
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.MustMatchers._
import org.scalatest.WordSpec
import play.api.libs.json.{Format, Json}

class UnmarshallingDDirectivesSpec extends WordSpec with DDirectivesSpec with ScalatestRouteTest {
  import UnmarshallingDDirectivesSpec._

  "Out" must {
    val now = LocalDate.now()

    "be applied to route documentation" in {
      Out[TestOut].describe(RouteDocumentation()).out mustBe Some(OutDocumentation(
        success = List(
          Payload.Success(
            status = Status(StatusCodes.OK),
            contentType = "application/json",
            schema = JsonSchema.resolveSchema[TestOut],
            example = None))))
    }
    "be applied to route documentation (concatenated)" in {
      val out = Out(StatusCodes.Created, TestOut("id", Some("name"), now)) & Out(StatusCodes.NotFound, "entity not found")
      out.describe(RouteDocumentation()).out mustBe Some(OutDocumentation(
        failure = List(
          Payload.Failure(
            status = Status(StatusCodes.NotFound),
            contentType = None,
            description = Some("entity not found"))),
        success = List(
          Payload.Success(
            status = Status(StatusCodes.Created),
            contentType = "application/json",
            schema = JsonSchema.resolveSchema[TestOut],
            example = Some(Json toJson TestOut("id", Some("name"), now))))))
    }
  }

}

object UnmarshallingDDirectivesSpec {
  case class TestOut(id: String, name: Option[String], createdAt: LocalDate)
  implicit val testInFormat: Format[TestOut] = Json.format[TestOut]
} 
开发者ID:evolution-gaming,项目名称:akka-http-documenteddsl,代码行数:52,代码来源:UnmarshallingDDirectivesSpec.scala


示例4: descriptor

//设置package包名称以及导入依赖的类
package sample.helloworldconsumer.api

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport.Method
import play.api.libs.json.{Format, Json}

trait HelloConsumerService extends Service {

  override def descriptor = {
    import Service._

    named("wordCounts").withCalls(
      restCall(Method.GET, "/api/wordcount", findTopHundredWordCounts _),
      restCall(Method.GET, "/api/foo", foo)
    ).withAutoAcl(true)
  }

  def findTopHundredWordCounts(): ServiceCall[NotUsed, Map[String, Int]]

  def foo(): ServiceCall[NotUsed, String]

  case class WordDetails(word: String, count: String)

  object WordDetails {
    implicit val format: Format[WordDetails] = Json.format
  }
} 
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:29,代码来源:HelloConsumerService.scala


示例5: AccountState

//设置package包名称以及导入依赖的类
package org.ioreskovic.greatmaterialcontinuum.impl.stt.acc

import org.ioreskovic.greatmaterialcontinuum.api.Account
import play.api.libs.json.{Format, Json}

object AccountState {
  implicit val format: Format[AccountState] = Json.format
}

case class AccountState(maybeAccount: Option[Account]) {
  def deactivate: AccountState = withActiveStatus(false)

  def activate: AccountState = withActiveStatus(true)

  def withActiveStatus(status: Boolean): AccountState = maybeAccount match {
    case Some(acc) => AccountState(Some(Account(acc.username, acc.password, active = status)))
    case _ => AccountState(None)
  }
} 
开发者ID:ioreskovic,项目名称:great-material-continuum,代码行数:20,代码来源:AccountState.scala


示例6: createPlayer

//设置package包名称以及导入依赖的类
package com.chriswk.gameranker.player.api

import java.util.UUID

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import play.api.libs.json.{Format, Json}

trait PlayerService extends Service {
  def createPlayer: ServiceCall[CreatePlayer, Player]

  def getPlayer(playerId: UUID): ServiceCall[NotUsed, Player]

  def getPlayers: ServiceCall[NotUsed, Seq[Player]]

  override def descriptor = {
    import Service._
    named("player").withCalls(
      pathCall("/api/player", createPlayer),
      pathCall("/api/player/:id", getPlayer _),
      pathCall("/api/player", getPlayers)
    )
  }
}

case class Player(id: UUID, name: String)

object Player {
  implicit val format: Format[Player] = Json.format
}

case class CreatePlayer(name: String)

object CreatePlayer {
  implicit val format: Format[CreatePlayer] = Json.format
} 
开发者ID:chriswk,项目名称:gameranker,代码行数:37,代码来源:PlayerService.scala


示例7: CoreMonitorStatus

//设置package包名称以及导入依赖的类
package org.wex.cmsfs.config.api

import play.api.libs.json.{Format, Json}

case class CoreMonitorStatus(id: Int, category: String, name: String, metric: String,
                             collect: Option[CoreMonitorStageStatus] = None,
                             analyze: Option[CoreMonitorStageStatus] = None,
                             alarm: Option[CoreMonitorStageStatus] = None)

object CoreMonitorStatus extends ((Int, String, String, String,
  Option[CoreMonitorStageStatus], Option[CoreMonitorStageStatus], Option[CoreMonitorStageStatus]) => CoreMonitorStatus) {
  implicit val format: Format[CoreMonitorStatus] = Json.format
}

case class CoreMonitorStageStatus(state: Boolean, timestamp: String, result: String)

object CoreMonitorStageStatus {
  implicit val format: Format[CoreMonitorStageStatus] = Json.format
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:20,代码来源:CoreMonitorStatus.scala


示例8: Status

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

import play.api.libs.json.{Format, JsString, JsSuccess, JsValue}

object Status extends Enumeration {

  type Status = Value
  val Inactive = Value(1, "Inactive")
  val Active = Value(2, "Active")
  val Deleted = Value(3, "Deleted")

  implicit val myEnumFormat = new Format[Status] {
    def reads(json: JsValue) = JsSuccess(Status.withName(json.as[String]))
    def writes(myEnum: Status) = JsString(myEnum.toString)
  }
} 
开发者ID:dtambussi,项目名称:pedidos,代码行数:17,代码来源:Status.scala


示例9: EstadoPedido

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

import play.api.libs.json.{Format, JsString, JsSuccess, JsValue}

object EstadoPedido extends Enumeration {

  type EstadoPedido = Value
  val Generado = Value(1, "Generado")
  val Pendiente = Value(2, "Pendiente")
  val Confeccionado = Value(3, "Confeccionado")
  val Entregado = Value(4, "Entregado")
  val Cancelado = Value(5, "Cancelado")

  implicit val myEnumFormat = new Format[EstadoPedido] {
    def reads(json: JsValue) = JsSuccess(EstadoPedido.withName(json.as[String]))
    def writes(myEnum: EstadoPedido) = JsString(myEnum.toString)
  }
} 
开发者ID:dtambussi,项目名称:pedidos,代码行数:19,代码来源:EstadoPedido.scala


示例10: Categoria

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

import play.api.libs.json.{Format, JsString, JsSuccess, JsValue}

object Categoria extends Enumeration {

  type Categoria = Value
  val Entradas = Value(1, "Entradas")
  val PlatosPrincipales = Value(2, "PlatosPrincipales")
  val Postres = Value(3, "Postres")
  val Bebidas = Value(4, "Bebidas")
  val Cafeteria = Value(5, "Cafeteria")

  implicit val myEnumFormat = new Format[Categoria] {
    def reads(json: JsValue) = JsSuccess(Categoria.withName(json.as[String]))
    def writes(myEnum: Categoria) = JsString(myEnum.toString)
  }
} 
开发者ID:dtambussi,项目名称:pedidos,代码行数:19,代码来源:Categoria.scala


示例11: Item

//设置package包名称以及导入依赖的类
package demo.api.basket

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import demo.api.basket.ExtraTransportExceptions.CustomExceptionSerializer
import play.api.Environment
import play.api.libs.json.{Format, Json}

case class Item(name: String, price: Int)
object Item {
  implicit val itemFormat: Format[Item] = Json.format
}

case class Basket(items: Seq[Item], total: Int)
object Basket {
  implicit val basketFormat: Format[Basket] = Json.format
}

case class OrderPlaced(basketId: String, basket: Basket)
object OrderPlaced {
  implicit val orderPlacedFormat: Format[OrderPlaced] = Json.format
}

trait BasketService extends Service {
  def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
  def getTotal(basketId: String): ServiceCall[NotUsed, Int]
  def addItem(basketId: String): ServiceCall[Item, NotUsed]
  def clearAll(basketId: String): ServiceCall[NotUsed, NotUsed]
  def placeOrder(basketId: String): ServiceCall[NotUsed, NotUsed]
  def placedOrders: Topic[OrderPlaced]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(GET, "/basket/:basketId/total", getTotal _),
      restCall(POST, "/basket/:basketId/items", addItem _),
      restCall(DELETE, "/basket/:basketId/items", clearAll _),
      restCall(POST, "/basket/:basketId/order", placeOrder _)
    ).withTopics(
      topic("placed-orders", placedOrders)
    ).withExceptionSerializer(new CustomExceptionSerializer(Environment.simple()))
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:49,代码来源:BasketService.scala


示例12: Item

//设置package包名称以及导入依赖的类
package demo.api.basket

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}

case class Item(name: String, price: Int)
object Item {
  implicit val itemFormat: Format[Item] = Json.format
}

case class Basket(items: Seq[Item], total: Int)
object Basket {
  implicit val basketFormat: Format[Basket] = Json.format
}

case class OrderPlaced(basketId: String, basket: Basket)
object OrderPlaced {
  implicit val orderPlacedFormat: Format[OrderPlaced] = Json.format
}

trait BasketService extends Service {
  def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
  def getTotal(basketId: String): ServiceCall[NotUsed, Int]
  def addItem(basketId: String): ServiceCall[Item, NotUsed]
  def clearAll(basketId: String): ServiceCall[NotUsed, NotUsed]
  def placeOrder(basketId: String): ServiceCall[NotUsed, NotUsed]
  def placedOrders: Topic[OrderPlaced]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(GET, "/basket/:basketId/total", getTotal _),
      restCall(POST, "/basket/:basketId/items", addItem _),
      restCall(DELETE, "/basket/:basketId/items", clearAll _),
      restCall(POST, "/basket/:basketId/order", placeOrder _)
    ).withTopics(
      topic("placed-orders", placedOrders)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:47,代码来源:BasketService.scala


示例13: OrderEntityFormats

//设置package包名称以及导入依赖的类
package demo.impl.order

import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
import play.api.libs.json.{Format, Json}

object OrderEntityFormats {
  implicit val orderItemsFormat: Format[OrderItems] = Json.format
  implicit val createOrderFormat: Format[CreateOrder] = Json.format
  implicit val getOrderFormat = JsonSerializer.emptySingletonFormat(GetOrder)
  implicit val orderInitialisedFormat: Format[OrderInitialized] = Json.format
  implicit val orderStateFormat: Format[OrderState] = Json.format
}

case class OrderItems (items: Seq[String])

trait OrderCommand
case class CreateOrder(items: Seq[String]) extends OrderCommand with ReplyType[Done]
case object GetOrder extends OrderCommand with ReplyType[OrderItems]

trait OrderEvent
case class OrderInitialized(items: Seq[String]) extends OrderEvent
case class OrderState(items: Seq[String])

object OrderState {
  def empty = OrderState(Seq())
}

class Order extends PersistentEntity {
  override type Command = OrderCommand
  override type Event = OrderEvent
  override type State = OrderState

  override def initialState = OrderState.empty

  override def behavior: Behavior = Actions()
    .onCommand[CreateOrder, Done] {
      case (CreateOrder(items), ctx, state) => {
        ctx.thenPersist(OrderInitialized(items)){
          evt => ctx.reply(Done)
        }
      }
    }
    .onReadOnlyCommand[GetOrder.type, OrderItems] {
      case (GetOrder, ctx, state) => ctx.reply(OrderItems(state.items))
    }
    .onEvent{
      case (OrderInitialized(items), state) => OrderState(items)
    }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:53,代码来源:Order.scala


示例14: Item

//设置package包名称以及导入依赖的类
package demo.api.basket

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}

case class Item(name: String, price: Int)
object Item {
  implicit val itemFormat: Format[Item] = Json.format
}

case class Basket(items: Seq[Item], total: Int)
object Basket {
  implicit val basketFormat: Format[Basket] = Json.format
}

trait BasketService extends Service {
  def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
  def getTotal(basketId: String): ServiceCall[NotUsed, Int]
  def addItem(basketId: String): ServiceCall[Item, NotUsed]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(GET, "/basket/:basketId/total", getTotal _),
      restCall(POST, "/basket/:basketId/items", addItem _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:34,代码来源:BasketService.scala


示例15: Item

//设置package包名称以及导入依赖的类
package demo.api.basket

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}

case class Item(name: String, price: Int)
object Item {
  implicit val itemFormat: Format[Item] = Json.format
}

case class Basket(items: Seq[Item], total: Int)
object Basket {
  implicit val basketFormat: Format[Basket] = Json.format
}

trait BasketService extends Service {
  def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
  def addItem(basketId: String): ServiceCall[Item, NotUsed]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(POST, "/basket/:basketId/items", addItem _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:32,代码来源:BasketService.scala


示例16: BasketEntityFormats

//设置package包名称以及导入依赖的类
package demo.impl.basket

import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, PersistentEntity}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
import demo.api.basket.{Basket, Item}
import play.api.libs.json.{Format, Json}

object BasketEntityFormats {
  implicit val addItemFormat: Format[AddItem] = Json.format
  implicit val getBasketFormat: Format[GetBasket.type] = JsonSerializer.emptySingletonFormat(GetBasket)
  implicit val itemAddedFormat: Format[ItemAdded] = Json.format
  implicit val basketEntityStateFormat: Format[BasketEntityState] = Json.format
}

trait BasketEntityCommand
case class AddItem(item: Item) extends BasketEntityCommand with ReplyType[Done]
case object GetBasket extends BasketEntityCommand with ReplyType[Basket]

case class BasketEntityState(currentBasket: Basket)
object BasketEntityState{
  val initial = BasketEntityState(Basket(Seq(), 0))
}

sealed trait BasketEntityEvent extends AggregateEvent[BasketEntityEvent] {
  override def aggregateTag = BasketEntityEvent.Tag
}

object BasketEntityEvent {
  val Tag = AggregateEventTag.sharded[BasketEntityEvent](4)
}

case class ItemAdded(item: Item) extends BasketEntityEvent

final class BasketEntity extends PersistentEntity {
  override type Command = BasketEntityCommand
  override type Event = BasketEntityEvent
  override type State = BasketEntityState

  override def initialState = BasketEntityState.initial

  override def behavior: Behavior = {
    Actions()
      .onCommand[AddItem, Done] {
        case (AddItem(item), ctx, state) =>
          ctx.thenPersist(ItemAdded(item))(_ => ctx.reply(Done))
      }
      .onReadOnlyCommand[GetBasket.type, Basket] {
        case (GetBasket, ctx, state) => ctx.reply(state.currentBasket)
      }
      .onEvent {
        case (ItemAdded(item), state) => {
          val newItems = state.currentBasket.items :+ item
          state.copy(Basket(newItems, newItems.map(_.price).sum))
        }
      }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:60,代码来源:BasketEntity.scala


示例17: Item

//设置package包名称以及导入依赖的类
package demo.api.basket

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import com.lightbend.lagom.scaladsl.api.transport._
import play.api.libs.json.{Format, Json}

case class Item(name: String, price: Int)
object Item {
  implicit val itemFormat: Format[Item] = Json.format
}

case class Basket(items: Seq[Item], total: Int)
object Basket {
  implicit val basketFormat: Format[Basket] = Json.format
}

trait BasketService extends Service {
  def getBasket(basketId: String): ServiceCall[NotUsed, Basket]
  def getTotal(basketId: String): ServiceCall[NotUsed, Int]
  def addItem(basketId: String): ServiceCall[Item, NotUsed]
  def clearAll(basketId: String): ServiceCall[NotUsed, NotUsed]

  override def descriptor: Descriptor = {
    import Method._
    import Service._

    named("basket").withCalls(
      restCall(GET, "/basket/:basketId", getBasket _),
      restCall(GET, "/basket/:basketId/total", getTotal _),
      restCall(POST, "/basket/:basketId/items", addItem _),
      restCall(DELETE, "/basket/:basketId/items", clearAll _)
    )
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:36,代码来源:BasketService.scala


示例18: sensorMapping

//设置package包名称以及导入依赖的类
package com.ss.mapping.api

import java.util.UUID

import akka.NotUsed
import com.lightbend.lagom.scaladsl.api.transport.Method
import com.lightbend.lagom.scaladsl.api.{Descriptor, Service, ServiceCall}
import play.api.libs.json.{Format, Json}

import scala.concurrent.Future


trait MappingService extends Service {

  def sensorMapping(nodeId: Long, sensorId: Int): ServiceCall[NotUsed, SensorMapping]
  def registerMapping(nodeId: Long, sensorId: Int): ServiceCall[SensorMapping, NotUsed]
  def unregisterMapping(nodeId: Long, sensorId: Int): ServiceCall[NotUsed, NotUsed]
  override final def descriptor: Descriptor = {
    import Service._
    named("mapping").withCalls(
      pathCall("/api/sensorMapping/nodes/:node/sensors/:sensor", sensorMapping _),
      pathCall("/api/sensorMapping/nodes/:node/sensors/:sensor", registerMapping _),
      restCall(Method.DELETE, "/api/sensorMapping/nodes/:node/sensors/:sensor", unregisterMapping _)
    ).withAutoAcl(true)
  }

}

case class GlobalSensorId(nodeId: Long, sensorId: Int)
case class SensorMapping(objectId: UUID, domain: String, metricName: String)
object GlobalSensorId {
  implicit val jsonFormat: Format[GlobalSensorId] = Json.format[GlobalSensorId]
}
object SensorMapping {
  implicit val jsonFormat: Format[SensorMapping] = Json.format[SensorMapping]
} 
开发者ID:ytaras,项目名称:iot_lagom_poc,代码行数:37,代码来源:MappingService.scala


示例19: Repo

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

import play.api.libs.json.{ Format, Json }
import scala.concurrent.Future


  case class Repo(
    id: Int,
    name: String,
    full_name: String,
    owner: Owner,
    `private`: Boolean,
    html_url: String,
    description: Option[String],
    fork: Boolean,
    url: String,
    forks_url: String,
    keys_url: String,
    collaborators_url: String,
    teams_url: String,
    hooks_url: String,
    issue_events_url: String,
    events_url: String,
    assignees_url: String,
    branches_url: String,
    tags_url: String,
    blobs_url: String,
    permissions: Permission
  )

  implicit val ownerFormat: Format[Owner] = Json.format[Owner]
  implicit val permissionFormat: Format[Permission] = Json.format[Permission]
  implicit val repoFormat: Format[Repo] = Json.format[Repo]
} 
开发者ID:lunatech-labs,项目名称:teahub,代码行数:35,代码来源:GitHubService.scala


示例20: Event

//设置package包名称以及导入依赖的类
package models
import org.joda.time.DateTime
import play.api.libs.json.{Json, Format}

case class Event(
  id: Option[Long],
  name: String,
  start: DateTime,
  end: DateTime,
  address: String,
  city: String,
  state: String,
  country: String)
  
object Event {
  implicit val format: Format[Event] = Json.format[Event]
} 
开发者ID:getmetorajesh,项目名称:rj_play_slick_events,代码行数:18,代码来源:Event.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala LoadAuditingConfig类代码示例发布时间:2022-05-23
下一篇:
Scala macros类代码示例发布时间: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