Skip to content

Commit

Permalink
Code changes to for new jackson
Browse files Browse the repository at this point in the history
  • Loading branch information
vihangpatil committed Oct 15, 2019
1 parent fd607a7 commit 1947b42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class EntityStore<E : Any>(

// convert object to map of (field name, field value)
// TODO: Fails to serialize datastore 'Value<*>' types such as 'StringValue'.
val map: MutableMap<String, Any?> = objectMapper.convertValue(entity, object : TypeReference<Map<String, Any?>>() {})
val map: Map<String, Any?> = objectMapper.convertValue(entity, object : TypeReference<Map<String, Any?>>() {})

val keyFactory = parents.fold(
initial = datastore.newKeyFactory().setKind(entityClass.qualifiedName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import org.ostelco.prime.jsonmapper.objectMapper

object JsonUtils {
fun compactJson(json: String): String = objectMapper.writeValueAsString(
objectMapper.readValue<Map<String, String>>(json, object : TypeReference<Map<String, Any>>() {}))
objectMapper.readValue<Map<String, Any>>(json, object : TypeReference<Map<String, Any>>() {}))
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SchemaTest {

@Test
fun `json to map`() {
val map = objectMapper.readValue<Map<String, String>>("""{"label":"3GB for 300 NOK"}""", object : TypeReference<LinkedHashMap<String, String>>() {})
val map = objectMapper.readValue<Map<String, String>>("""{"label":"3GB for 300 NOK"}""", object : TypeReference<Map<String, String>>() {})
assertEquals("3GB for 300 NOK", map["label"])
}

Expand Down

0 comments on commit 1947b42

Please sign in to comment.