diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java index c81b916f8..fe9f81823 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java @@ -235,17 +235,19 @@ private void persistAggregation(NGSIGenericAggregator aggregator) throws CygnusP JsonElement attType; if (rowAttrPersistence) { attType = aggregator.getAggregation().get(NGSIConstants.ATTR_TYPE).get(i); - if ( (attType != null) && - (attType.toString().contains("ISO8601") || - attType.toString().contains("DateTime")) ) { + if ( (attType != null && + attType.isJsonPrimitive()) && + (attType.getAsString().equals("ISO8601") || + attType.getAsString().equals("DateTime")) ) { basicDBObject = castDate(NGSIConstants.ATTR_VALUE, basicDBObject); } } else { for (String key : basicDBObject.keySet()) { attType = aggregator.getAggregation().get(key + NGSIConstants.AUTOGENERATED_ATTR_TYPE).get(i); - if ( (attType != null) && - (attType.toString().contains("ISO8601") || - attType.toString().contains("DateTime")) ) { + if ( (attType != null && + attType.isJsonPrimitive()) && + (attType.getAsString().equals("ISO8601") || + attType.getAsString().equals("DateTime")) ) { basicDBObject = castDate(key, basicDBObject); } }