Hi,
I think it is a good way, yes. You could also handle the JSON parsing in a
custom input format but this would only shift the computation to a
different place. Performance should not be impacted by this. (I think
parsing JSON is slow no matter what you do and not matter what cluster
processing framework you use. :D)

Aljoscha


On Fri, Aug 8, 2014 at 12:49 PM, Norman Spangenberg <
[email protected]> wrote:

> Hello Aljoscha,
> Thanks for your reply. It was really helpful.
> After some time to figure out the right syntax it worked perfectly.
>
> val user_interest = lines.map( line => {
>                                         val parsed = parse(line)
>
>                                         implicit lazy val formats =
> org.json4s.DefaultFormats
>                                         val name =
> parsed.\("name").extract[String]
>                                         val location_x =
> parsed.\("location").\("x").extract[Double]
>                                         val location_y =
> parsed.\("location").\("y").extract[Double]
>                                         val likes =
> parsed.\("likes").extract[Seq[String]].map(_.toLowerCase()).mkString(";")
>
>                                         ( UserInterest(name, location_x,
> location_y, likes) )
>                                     })
>
> Is this the best way to handle with json data? or is there a more
> efficient way?
>
> thank you,
> norman
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>

Reply via email to