Posts

Showing posts with the label spark-streaming

how do I fix the type mismatch issue?

how do I fix the type mismatch issue? I have a spark streaming job and had a question about type converting. the below is my code: val component = data.get("viewed_objects").get.asInstanceOf[ListBuffer[Map[String, Any]]] but the exception is scala.collection.immutable.$colon$colon cannot be cast to scala.collection.ListBuffer what caused the issue and how do I fix it? yes,it is a json String,like this: u'data': {u'viewed_objects': [{u'location': 3, u'keyword': u'baby carriers'}]} – Zhang Xin Jul 1 at 3:47 I print the data value, it is for example: data:Map(viewed_objects -> List(Map(location -> 2, category_name -> Toys, Kids & Babies, category_id -> 27))), how do I get the viewed_objects and traversal the elements ...