Here is the code I tried:
if(rs.next()){
Gson gson = new Gson();
STRUCT st = (STRUCT) rs.getObject(1);
JGeometry j_geom = JGeometry.load(st);
System.out.println(" gson.toJson(j_geom) "+gson.toJson(j_geom));
}
But I am getting this error:
java.lang.IllegalArgumentException: NaN is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialDoubleValues() method.
Cannot find a way to sort it out.
Did you try using GsonBuilder.serializeSpecialFloatingPointValues()
? The exception mentions serializeSpecialDoubleValues()
, which does not seem to exist.
That JavaDoc states:
Section 2.4 of JSON specification disallows special double values (NaN, Infinity, -Infinity). However, Javascript specification (see section 4.3.20, 4.3.22, 4.3.23) allows these values as valid Javascript values. Moreover, most JavaScript engines will accept these special values in JSON without problem. So, at a practical level, it makes sense to accept these values as valid JSON even though JSON specification disallows them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.