Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save retrospectacus/ae44da59ffd21ca34b5d294a9343fe42 to your computer and use it in GitHub Desktop.
Save retrospectacus/ae44da59ffd21ca34b5d294a9343fe42 to your computer and use it in GitHub Desktop.
import play.api.libs.json.Json
val j= """
|[
| {
| "_key": "A1",
| "name": "Foo and Bar",
| "contents": [
| {
| "Android Wear": [
| "Notifications",
| "Voice Actions",
| "Datenaustausch",
| "Listen"
| ],
| "Android Lollipop & Marshmallow": [
| "App Bar",
| "Material Design",
| "Styling & Theming",
| "Data Binding",
| "Transitions",
| "Rechte Management",
| "Android TV",
| "Floating Toolbar",
| "Recycler Views"
| ],
| "API's": [
| "Google Maps & Position",
| "Google Locations",
| "Google Sign in"
| ]
| }
| ],
| "level": 2
| },
| {
| "_key": "A2",
| "name": "More Foo and Bar",
| "contents": [
| {
| "Android Wear": [
| "Notifications",
| "Voice Actions",
| "Datenaustausch",
| "Listen"
| ],
| "Android Lollipop & Marshmallow": [
| "App Bar",
| "Material Design",
| "Styling & Theming",
| "Data Binding",
| "Transitions",
| "Rechte Management",
| "Android TV",
| "Floating Toolbar",
| "Recycler Views"
| ],
| "API's": [
| "Google Maps & Position",
| "Google Locations",
| "Google Sign in"
| ]
| }
| ],
| "level": 2
| }
|
|]""".stripMargin
case class Course( _key: String, name: String, contents: Seq[Map[String, Seq[String]]])
implicit val readsCourse = Json.reads[Course]
val t: Seq[Course] = Json.parse(j).as[Seq[Course]]
println(t)
#
List(Course(A1,Foo and Bar,List(Map(Android Wear -> List(Notifications, Voice Actions, Datenaustausch, Listen), Android Lollipop & Marshmallow -> List(App Bar, Material Design, Styling & Theming, Data Binding, Transitions, Rechte Management, Android TV, Floating Toolbar, Recycler Views), API's -> List(Google Maps & Position, Google Locations, Google Sign in)))), Course(A2,More Foo and Bar,List(Map(Android Wear -> List(Notifications, Voice Actions, Datenaustausch, Listen), Android Lollipop & Marshmallow -> List(App Bar, Material Design, Styling & Theming, Data Binding, Transitions, Rechte Management, Android TV, Floating Toolbar, Recycler Views), API's -> List(Google Maps & Position, Google Locations, Google Sign in)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment