xuwei-k / scalapb-playjson   0.5.0

MIT License GitHub

Json/Protobuf convertors for ScalaPB use play-json

Scala versions: 2.12 2.11 2.10
Scala.js versions: 0.6

scalapb-playjson Build Status

scaladoc

The structure of this project is hugely inspired by scalapb-json4s

Dependency

Include in your build.sbt file

core

libraryDependencies += "io.github.scalapb-json" %% "scalapb-playjson" % "0.13.1"

for scala-js

libraryDependencies += "io.github.scalapb-json" %%% "scalapb-playjson" % "0.13.1"

macros

libraryDependencies += "io.github.scalapb-json" %% "scalapb-playjson-macros" % "0.13.1"

Usage

There are four functions you can use directly to serialize/deserialize your messages:

JsonFormat.toJsonString(msg) // returns String
JsonFormat.toJson(msg) // returns JsObject

JsonFormat.fromJsonString(str) // return MessageType
JsonFormat.fromJson(json) // return MessageType

Credits

fork from https://github.com/whisklabs/scalapb-playjson