本文整理汇总了Scala中org.json4s.jackson.JsonMethods.pretty类的典型用法代码示例。如果您正苦于以下问题:Scala pretty类的具体用法?Scala pretty怎么用?Scala pretty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pretty类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: StreamRecord
//设置package包名称以及导入依赖的类
package com.bwsw.tstreamstransactionserver.netty.server.streamService
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream
import com.bwsw.tstreamstransactionserver.rpc
import com.bwsw.tstreamstransactionserver.netty.server.streamService
import org.json4s._
import org.json4s.jackson.JsonMethods.{parse, pretty, render}
case class StreamRecord(key: StreamKey, stream: streamService.StreamValue)
extends rpc.Stream
{
override def id: Int = key.id
override def name: String = stream.name
override def partitions: Int = stream.partitions
override def ttl: Long = stream.ttl
override def description: Option[String] = stream.description
override def zkPath: String = stream.zkPath.get
def toBinaryJson: Array[Byte] = {
implicit val formats = DefaultFormats
pretty(render(Extraction.decompose(this))).getBytes
}
}
object StreamRecord {
def fromBinaryJson(bytes: Array[Byte]): StreamRecord = {
implicit val formats = DefaultFormats
parse(new ByteInputStream(bytes, bytes.length))
.extract[StreamRecord]
}
}