public String toMinimizedJsonString ( ) { try { final Map < String , Object > json = new LinkedHashMap <> ( ) ; json . put ( "alert" , this . message . getAlert ( ) ) ; if ( this . getMessage ( ) . getBadge ( ) > 0 ) { json . put ( "badge" , Integer . toString ( this . getMessage ( ) . getBadge ( ) ) ) ; } json . put ( "config" , this . config ) ; // we strip down the criteria too, as alias/category can be quite long, based on use-case final Map < String , Object > shrinkedCriteriaJSON = new LinkedHashMap <> ( ) ; shrinkedCriteriaJSON . put ( "variants" , this . criteria . getVariants ( ) ) ; shrinkedCriteriaJSON . put ( "deviceType" , this . criteria . getDeviceTypes ( ) ) ; json . put ( "criteria" , shrinkedCriteriaJSON ) ; return OBJECT_MAPPER . writeValueAsString ( json ) ; } catch ( JsonProcessingException e ) { return "[\"invalid json\"]" ; } catch ( IOException e ) { return "[\"invalid json\"]" ; } }
Returns a minimized JSON representation of the payload . This does not include potentially large objects like alias or category from the given criteria .