GithubHelp home page GithubHelp logo

binshi / spray-json-annotation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exnexu/spray-json-annotation

1.0 2.0 0.0 27 KB

kifi/json-annotation for spray

License: MIT License

Scala 100.00%

spray-json-annotation's Introduction

spray-json-annotation

Build Status Coverage Status

Scala macro annotations generating spray-json JsonFormats for case classes.

Get started

Add this to your build.sbt (for Scala 2.10 & 2.11):

resolvers += "bleibinha.us/archiva releases" at "http://bleibinha.us/archiva/repository/releases"

libraryDependencies ++= Seq(
  "us.bleibinha" %% "spray-json-annotation" % "0.6"
)

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)

Use it in code:

import spray.json._
import spray.json.DefaultJsonProtocol._
import us.bleibinha.spray.json.macros._

@jsonstrict
case class User(name: String, password: String)

This will be generated by the compiler:

@jsonstrict
case class User(name: String, password: String)

object User {
  implicit val jsonAnnotationFormat: RootJsonFormat[User] = jsonFormat2(User.apply)
}

@json can be used if the case class has only one field and you don't want to generate a full-blown json object. For more usage examples see the test implementation: JsonFormatAnnotationTest.scala

Version history

0.6

  • Add support for final case class

0.5

  • Update dependency and plugin versions

0.4

  • First stable release

Background

Code base from kifi/json-annotation which provides json annotations for play-json. More information on their blog: http://eng.kifi.com/scala-macro-annotations-real-world-example/

This implements the same annotiations but with spray/spray-json as the underlying Scala json library.

License

MIT License

spray-json-annotation's People

Contributors

exnexu avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar Conan, the barbarian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.