Reputation: 391
Trying to convert Apache Flink Source String to Map using scala.
My Source Streaming String : key1=value1key2=2000-12-17 00:00:00key3=Testkey4=08.89198key5=103.000
Code :
val environment = StreamExecutionEnvironment.getExecutionEnvironment
val out = environment.addSource(...)
val mapper = new ObjectMapper()
val texToMap = out.map(mapper.readValue(_,classOf[Map[Object,Object]])
println(textToJson)
Its throwing error like
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'key1': was expecting ('true', 'false' or 'null')
Is there any way to transform the String value to Map since i'm new to flink implementation.
Upvotes: 0
Views: 1218
Reputation: 1009
Apache Flink uses jackson shaded jar for some special uses. In your case, you need to import com.fasterxml.jackson.databind.ObjectMapper
instead of Flink's shaded jackson dependency.
And at the same time, you need this because you're using Scala.
import com.fasterxml.jackson.module.scala.DefaultScalaModule
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
Upvotes: 1