Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Scala for Java Developers
  • Toc
  • feedback
Scala for Java Developers

Scala for Java Developers

By : Thomas Alexandre
4.3 (16)
close
Scala for Java Developers

Scala for Java Developers

4.3 (16)
By: Thomas Alexandre

Overview of this book

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

Working with XML and JSON


XML and JSON are the dominant formats to structure data that can be exchanged between parts of a system such as backend-frontend or between external systems. In Scala, there is some out-of-the-box support in the Scala library to manipulate both.

Manipulating XML

We have briefly seen earlier in this chapter as well as in Chapter 3, Understanding the Scala Ecosystem, when working with HTTP that XML documents can be created as literals and transformed in many ways. For instance, if we launch an REPL by typing > play console from a Play project root directory, we can start experimenting with XML:

scala> val books =
       <Library>
         <book title="Programming in Scala" quantity="15" price="30.00" />
         <book title="Scala for Java Developers" quantity="10" price="25.50" />
       </Library>
books: scala.xml.Elem = 
<Library>
  <book title="Programming in Scala" quantity="15" price="30.00"/>
  <book title="Scala for...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete