Created
April 25, 2016 22:11
-
-
Save retrospectacus/ae44da59ffd21ca34b5d294a9343fe42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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