Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created December 30, 2011 15:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save takezoe/1540223 to your computer and use it in GitHub Desktop.
Save takezoe/1540223 to your computer and use it in GitHub Desktop.
Example of scala.util.parsing.json
import scala.util.parsing.json._
val result = JSON.parseFull("""
{"name": "Naoki", "lang": ["Java", "Scala"]}
""")
result match {
case Some(e) => println(e) // => Map(name -> Naoki, lang -> List(Java, Scala))
case None => println("Failed.")
}
@cvasani
Copy link

cvasani commented Mar 16, 2014

Thanks TakeZoe .

@haiy
Copy link

haiy commented May 21, 2015

Mark

@niladri30
Copy link

thanks

@sasikanthpotu
Copy link

I need to write Scala program combined data from the two different files.
The file starting with assets_ contains asset. Each line represents 1 asset impression. The file starting ad-events_ contains various kinds of ad events. Each line represents one ad event. We are interested only in two kinds of ad events - 'view' and 'click'. Rest of the ad events should be ignored. Type of ad event is specified in the value of the field 'e'. You can see "e":"view" and "e":"click" in the json messages.

Each line also has another id called 'page view id'. This id is specified by json key 'pv'. You can find json key values similar to "pv":"7963ee21-0d09-4924-b315-ced4adad425f" in both the files.

The aim is to join the data in two files using "pv". You need to parse these files and combine the data in two files to check how many asset impressions, views and clicks are present in both the files for each page view id. the input files are .gz.

If it possible can you help me regarding this task?

@mohndoss
Copy link

If you can please help me to return above value as map

@dmigo
Copy link

dmigo commented Apr 30, 2020

It seems to be deprecated. Do you know if there is a new example somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment