Hi,
I'm having problems related to parsing of Json. I'm working with
groovy, using JsonSlurper to parse Json, but I'm getting the following
exception:
java.lang.IllegalStateException: Illegal type in JsonObject: class
java.math.BigDecimal
at io.vertx.core.json.impl.Json.checkAndCopy(Json.java:94)
at io.vertx.core.json.JsonObject.copy(JsonObject.java:341)
at io.vertx.core.json.impl.Json.checkAndCopy(Json.java:81)
...
Looking at the source code, it seems that BigDecimal isn't being
processed, in Json.java, line 63, mehod checkAndCopy:
...
} else if (val instanceof Number && !(val instanceof BigDecimal)) {
...
The funny thing is that the number in cuestion isn't a "big" decimal,
but JsonSlurper always uses BigDecimal, check
http://groovy.329449.n5.nabble.com/What-kind-of-numbers-for-JSON-parsing-td5004287.html
Related to this, I tried to work with JsonObject instead of
JsonSlurper, using the method getMap (in the same way of
wrapObject/unwrapObject in lang.groovy.InternalHelper of
verxt-groovy), but the "inner" objects of the resultant map aren't
maps, but instances of JsonObject, so an expressión like:
jsonObj.someList[0].aProperty
has to be transformed to:
jsonObj.someList[0].getString('aProperty') or
jsonObj.someList[0].getMap().aProperty
This doesn't work for me, because it ties JsonObject to other parts of
my system and breaks my unit tests :p
Ah!, btw, amazing project, We have a couple of systems up and running
using vertx2 and vertx3 looks promising. Any help/advice would be
appreciated.
best regards, Jorge Riquelme