This repository was archived by the owner on Aug 18, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
src/main/scala/org/codeoverflow/chatoverflow/connector/actor Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,8 @@ libraryDependencies ++= Seq(
53
53
// "com.typesafe.akka" %% "akka-testkit" % "2.5.18" % Test
54
54
)
55
55
56
- // Akka Actors
57
- libraryDependencies ++= Seq (
58
- " com.typesafe.akka" %% " akka-actor" % " 2.5.18" ,
59
- // "com.typesafe.akka" %% "akka-testkit" % "2.5.18" % Test
60
- )
56
+ // https://mvnrepository.com/artifact/com.google.code.gson/gson
57
+ libraryDependencies += " com.google.code.gson" % " gson" % " 2.8.5"
61
58
62
59
63
60
// ---------------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1
1
package org .codeoverflow .chatoverflow .connector .actor
2
2
3
3
import akka .actor .Actor
4
+ import com .google .gson .{JsonObject , JsonParser }
4
5
6
+ /**
7
+ * The JSON Actor uses Google GSON to parse serialized json and enable traversing.
8
+ */
5
9
class JsonActor extends Actor {
6
- override def receive : Receive = ???
10
+ val parser = new JsonParser
11
+
12
+ /**
13
+ * Receives a ParseJSON Object to start parsing.
14
+ *
15
+ * @return the desired values, can be any type
16
+ */
17
+ override def receive : Receive = {
18
+ case ParseJSON (json, parse) =>
19
+ val rootObject = parser.parse(json).getAsJsonObject
20
+ parse(rootObject)
21
+ }
7
22
}
23
+
24
+ /**
25
+ * Send a ParseJSON-object to start parsing. The traversal is custom.
26
+ *
27
+ * @param json the serialized json string
28
+ * @param parse a function what should happen with the parsed json. Return type is any
29
+ */
30
+ case class ParseJSON (json : String , parse : JsonObject => Any )
You can’t perform that action at this time.
0 commit comments