Skip to content

Commit a2f6df4

Browse files
author
Dragos Manolescu
committed
Added play-json
1 parent 688a926 commit a2f6df4

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

build.sbt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ libraryDependencies ++= Seq (
5151
"io.spray" %% "spray-json" % "1.2.3",
5252
"com.yammer.metrics" % "metrics-core" % "2.1.3",
5353
"fr.janalyse" %% "janalyse-jmx" % "0.6.1" % "compile",
54-
"net.sf.jopt-simple" % "jopt-simple" % "4.4"
54+
"net.sf.jopt-simple" % "jopt-simple" % "4.4",
55+
"play" % "play-json_2.10" % "2.2-SNAPSHOT"
5556
)
5657

5758
/* you may need these repos */
5859
resolvers ++= Seq(
59-
"spray" at "http://repo.spray.io",
60-
"coda" at "http://repo.codahale.com",
61-
"JAnalyse Repository" at "http://www.janalyse.fr/repository/"
60+
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
61+
"spray" at "http://repo.spray.io/",
62+
"coda" at "http://repo.codahale.com/",
63+
"JAnalyse Repository" at "http://www.janalyse.fr/repository/",
64+
Resolver.file("Local Repository", file("/Users/dragos.manolescu/Repos/Play20/repository/local"))(Resolver.ivyStylePatterns) // really? https://github.com/playframework/Play20/wiki/BuildingFromSource
6265
)
6366

6467
/* sbt behavior */

src/main/scala/com/microWorkflow/jsonScalaPerftest/Experiment.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ object Experiment {
5353
, new twitter.TwitterAdaptor("twitter")
5454
, new scalalib.ScalaLibAdaptor("scalalib")
5555
, new jackson.JacksonAdaptor("jackson")
56+
, new play.PlayAdaptor("play")
5657
)
5758
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.microWorkflow.jsonScalaPerftest.play
2+
3+
import com.microWorkflow.jsonScalaPerftest.LibraryAdaptor
4+
import play.api.libs.json._
5+
6+
case class Url(indices: Array[Int], url: String)
7+
8+
case class HashTag(indices: Array[Int], text:String)
9+
10+
case class UserMention(indices: Array[Int], name: String)
11+
12+
case class Entities(hashtags: Array[HashTag], urls:Array[Url], user_mentions:Array[UserMention])
13+
14+
case class Tweet(id_str: String, text: String, entities: Entities)
15+
16+
17+
class PlayAdaptor(name: String) extends LibraryAdaptor(name) {
18+
implicit val urlReads = Json.reads[Url]
19+
implicit val hashTagReads = Json.reads[HashTag]
20+
implicit val userMentionReads = Json.reads[UserMention]
21+
implicit val entitiesReads = Json.reads[Entities]
22+
implicit val tweetReads = Json.reads[Tweet]
23+
24+
def hasMap = true
25+
26+
def initialize() {}
27+
28+
def parseOnce(json: String) = {
29+
Json.parse(json)
30+
}
31+
32+
def mapOnce(json: String) = {
33+
34+
val parsed = Json.parse(json)
35+
parsed.as[Tweet]
36+
}
37+
}

0 commit comments

Comments
 (0)