Working with JSON in Scala

  • Scala does not support JSON. You need to use 3rd party library. This post is about my experiments with usage the JSON in Scala with three libraries:
  • argonaut
  • json4s
  • spray

Source code is here: https://github.com/ysden123/poc/tree/master/scala-json

Argonaut

See http://argonaut.io/

Code with examples:

  • argonaut/QuickStartExample – base operations on JSON
  • argonaut/RequestResponse – example of JSON request handling

json4s

See http://json4s.org/

Code with examples:

  • json4s/ArrayParser – parses JSON with array of objects
  • json4s/ArrayParserWithExtract – parses JSON with array of objects using extract
  • json4s/ArrayParserWithRead – parses JSON with array of objects using read
  • json4s/JsonProducer – producing JSON
  • json4s/JsonWriter – converts an object or objects to JSON string
  • json4s/Parser – parsing JSON
  • json4s/ParserWithExtract – parses JSON using extract
  • json4s/ParserWithRead – parses JSON using read

Spray-json

See https://github.com/spray/spray-json

Code with examples:

  • spray/SprayJsonSimple – base operations on JSON
  • spray/ColorTest – converting to/from case class

Remark. Spary-json has limitation for number of parameters in a case class – no more than 22.

Conclusion

Most comfortable, at least for me, are libraries: json4s and spray-json

Advertisements

About ysden123

We are not only for work... All my time free from work I spend on photography. Most photos are from our travels. I like make photos in still life style as well.
This entry was posted in Programming, Scala and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s