|
1 | 1 | package com.microWorkflow.jsonScalaPerftest.jackson
|
2 | 2 |
|
3 | 3 | import com.microWorkflow.jsonScalaPerftest.LibraryAdaptor
|
4 |
| -import com.fasterxml.jackson.databind.ObjectMapper |
5 |
| -//import com.fasterxml.jackson.module.scala.DefaultScalaModule |
| 4 | +import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper} |
| 5 | +import com.microWorkflow.jsonScalaPerftest.domain.{Place, Tweet} |
6 | 6 |
|
7 |
| -case class Url(indices: Array[Int], url: String) |
8 |
| - |
9 |
| -case class HashTag(indices: Array[Int], text:String) |
10 |
| - |
11 |
| -case class UserMention(indices: Array[Int], name: String) |
12 |
| - |
13 |
| -case class Entities(hashtags: Array[HashTag], urls:Array[Url], user_mentions:Array[UserMention]) |
14 |
| - |
15 |
| -case class Tweet(id_str: String, text: String, entities: Entities) |
| 7 | +import com.fasterxml.jackson.module.scala.DefaultScalaModule |
16 | 8 |
|
17 | 9 | class JacksonAdaptor(name: String) extends LibraryAdaptor(name) {
|
18 | 10 |
|
19 | 11 | var m: ObjectMapper = _
|
20 | 12 |
|
21 | 13 | override def initialize() {
|
22 | 14 | m = new ObjectMapper
|
23 |
| -// m.registerModule(new DefaultScalaModule) |
24 |
| -// m.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
| 15 | + m.registerModule(new DefaultScalaModule) |
| 16 | + m.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
25 | 17 | }
|
26 | 18 |
|
27 | 19 | override def parseOnce(json: String) = {
|
28 | 20 | m.readTree(json)
|
29 | 21 | }
|
30 | 22 |
|
31 |
| - override def mapOnce(json: String) = { |
| 23 | + override def mapTweet(json: String) = { |
32 | 24 | m.readValue(json, classOf[Tweet])
|
33 | 25 | }
|
34 | 26 |
|
| 27 | + override def mapPlace(json: String) = { |
| 28 | + m.readValue(json, classOf[Place]) |
| 29 | + } |
| 30 | + |
35 | 31 | override def hasMap = true
|
36 | 32 | }
|
0 commit comments