File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed
src/main/scala/com/microWorkflow/jsonScalaPerftest Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,17 @@ libraryDependencies ++= Seq (
51
51
" io.spray" %% " spray-json" % " 1.2.3" ,
52
52
" com.yammer.metrics" % " metrics-core" % " 2.1.3" ,
53
53
" 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"
55
56
)
56
57
57
58
/* you may need these repos */
58
59
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
62
65
)
63
66
64
67
/* sbt behavior */
Original file line number Diff line number Diff line change @@ -53,5 +53,6 @@ object Experiment {
53
53
, new twitter.TwitterAdaptor (" twitter" )
54
54
, new scalalib.ScalaLibAdaptor (" scalalib" )
55
55
, new jackson.JacksonAdaptor (" jackson" )
56
+ , new play.PlayAdaptor (" play" )
56
57
)
57
58
}
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments