vert-x / mod-lang-scala

Vert.x 2.x is deprecated - use instead
https://github.com/vert-x3/vertx-lang-scala
Apache License 2.0
77 stars 35 forks source link

Json get should return option instead of null #158

Open angeloh opened 10 years ago

angeloh commented 10 years ago

This is my json looks like:

{"address":"eb.local2","body":{"status":"ok","result":{"memberId":"memberid1","sys_pres":"connected","presence":"Online"}}}

It is really difficult to test a value in a deeper level.

if (json.getObject("body") != null && json.getObject("body").getObject("result") != null &&
                json.getObject("body").getObject("result").getString("presence") != null &&                json.getObject("body").getObject("result").getString("presence").equals("Online"))
dosomething()
galderz commented 10 years ago

Yeah, our current JSON API is essentially the same as the Java API. This is something we'll be looking to rectify for 2.0. Rather coming up with a new JSON API within Scala, we might look into existing functional libraries to handle JSON, such as Argonaut (http://argonaut.io/).