Book Image

Scala for Java Developers

By : Thomas Alexandre
Book Image

Scala for Java Developers

By: Thomas Alexandre

Overview of this book

Table of Contents (19 chapters)
Scala for Java Developers
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Handling Play requests with XML and JSON


Now that we are familiar with the JSON and XML formats, we can start using them to handle HTTP requests and responses in the context of a Play project.

To exhibit these behaviors, we are going to call an online web service, the iTunes media library, which is available and documented at http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html.

It returns JSON messages on search invocations. We can, for instance, call the API with the following URL and parameters:

https://itunes.apple.com/search?term=angry+birds&country=se&entity=software

The term parameter filters every item in the library that has to do with Angry Birds and the entity parameter retains only software items. We also apply an additional filter to query only the Swedish App Store.

Note

If you don't have it already in your build.sbt file, you may need to add the dispatch dependency at this point, the same way we did while working with...