3636import org .springframework .stereotype .Service ;
3737
3838import java .io .IOException ;
39+ import java .math .BigDecimal ;
3940import java .time .Instant ;
4041import java .time .LocalDateTime ;
4142import java .util .ArrayList ;
@@ -376,6 +377,10 @@ private static void convertToCollectedVar(
376377 Map <String , Object > states = JsonUtils .asMap (collectedVariable .getValue ());
377378
378379 // nothing if no state
380+ if (states == null || states .isEmpty ()) {
381+ continue ;
382+ }
383+
379384 if (states .containsKey (stateKey )) {
380385 Object value = states .get (stateKey );
381386
@@ -388,7 +393,7 @@ private static void convertToCollectedVar(
388393 // scalaire non null ?
389394 if (value != null && !(value instanceof List <?>)) {
390395 // idem: on garde convertOneVar(entry, String, ...)
391- convertOneVar (collectedVariable , String . valueOf (value ), variablesMap , 1 , dest );
396+ convertOneVar (collectedVariable , getValueString (value ), variablesMap , 1 , dest );
392397 }
393398 }
394399 }
@@ -461,4 +466,15 @@ public Page<LunaticJsonRawDataModel> findRawDataByCampaignIdAndDate(String campa
461466
462467 }
463468
469+ //Utils
470+ protected static String getValueString (Object value ) {
471+ if (value instanceof Double || value instanceof Float ) {
472+ BigDecimal bd = new BigDecimal (value .toString ());
473+ return bd .stripTrailingZeros ().toPlainString ();
474+ }
475+ if (value instanceof Number ) {
476+ return value .toString ();
477+ }
478+ return String .valueOf (value );
479+ }
464480}
0 commit comments