Class JsonWritingUtils


  • public class JsonWritingUtils
    extends Object
    • Constructor Detail

      • JsonWritingUtils

        public JsonWritingUtils()
    • Method Detail

      • writeMapStringFields

        public static void writeMapStringFields​(JsonGenerator generator,
                                                String fieldName,
                                                Map<String,​String> map)
                                         throws IOException
        Writes a map as String fields to the generator if and only if the fieldName and values are not null.
        Throws:
        IOException
      • writeMapStringFields

        public static void writeMapStringFields​(JsonGenerator generator,
                                                String fieldName,
                                                Map<String,​String> map,
                                                boolean lowerCaseKeys)
                                         throws IOException
        Writes a map as String fields to the generator if and only if the fieldName and values are not null.
        Parameters:
        lowerCaseKeys - when true, the map keys will be written in lowercase.
        Throws:
        IOException
      • writeStringArrayField

        public static void writeStringArrayField​(JsonGenerator generator,
                                                 String fieldName,
                                                 String[] fieldValues)
                                          throws IOException
        Writes an array of strings to the generator if and only if the fieldName and values are not null.
        Throws:
        IOException
      • writeStringField

        public static void writeStringField​(JsonGenerator generator,
                                            String fieldName,
                                            String fieldValue)
                                     throws IOException
        Writes the field to the generator if and only if the fieldName and fieldValue are not null.
        Throws:
        IOException
      • writeNumberField

        public static void writeNumberField​(JsonGenerator generator,
                                            String fieldName,
                                            int fieldValue)
                                     throws IOException
        Writes the field to the generator if and only if the fieldName is not null.
        Throws:
        IOException
      • writeNumberField

        public static void writeNumberField​(JsonGenerator generator,
                                            String fieldName,
                                            long fieldValue)
                                     throws IOException
        Writes the field to the generator if and only if the fieldName is not null.
        Throws:
        IOException
      • isNotNullOrEmpty

        public static boolean isNotNullOrEmpty​(String value)