Class ApiJsonParser

    • Constructor Detail

      • ApiJsonParser

        public ApiJsonParser()
    • Method Detail

      • stringValue

        protected static String stringValue​(JsonValue value)
        Get a string value from a json value.
        Parameters:
        value - Json value
        Returns:
        string representation of the value.
        Throws:
        ApiException - in case the value is array or object
      • toList

        protected static List<String> toList​(JsonObject json,
                                             String name)
        Convert a JSON array in the JSON object to a list of strings.
        Parameters:
        json - JSON object
        name - name of the array in the object
        Returns:
        list from the array, or empty if the array does not exist or is null
      • toBytesBase64

        protected static Optional<byte[]> toBytesBase64​(JsonObject json,
                                                        String name)
        Get bytes from a base64 string value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        bytes or empty if the property does not exist or is null
      • toObject

        protected static Optional<JsonObject> toObject​(JsonObject json,
                                                       String name)
        Get a child JSON object.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        JSON object or empty if the property does not exist or is null
      • toString

        protected static Optional<String> toString​(JsonObject json,
                                                   String name)
        Get a string value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        string or empty if the property does not exist or is null
      • toInt

        protected static Optional<Integer> toInt​(JsonObject json,
                                                 String name)
        Get an int value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        int or empty if the property does not exist or is null
      • toLong

        protected static Optional<Long> toLong​(JsonObject json,
                                               String name)
        Get a long value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        long or empty if the property does not exist or is null
      • toDouble

        protected static Optional<Double> toDouble​(JsonObject json,
                                                   String name)
        Get a double value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        double or empty if the property does not exist or is null
      • toBoolean

        protected static Optional<Boolean> toBoolean​(JsonObject json,
                                                     String name)
        Get a boolean value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        boolean or empty if the property does not exist or is null
      • toInstant

        protected static Optional<Instant> toInstant​(JsonObject json,
                                                     String name,
                                                     DateTimeFormatter formatter)
        Get an Instant value.
        Parameters:
        json - JSON object
        name - name of the property
        formatter - to use when parsing the string value
        Returns:
        instant or empty if the property does not exist or is null
      • toMap

        protected static Map<String,​String> toMap​(JsonObject json,
                                                        String name)
        Get a map value.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        map with property key/value pairs, or empty if the property does not exist or is null
      • isPresent

        protected static Optional<Boolean> isPresent​(JsonObject json,
                                                     String name)
        If the property is present on the JSON object, returns a non-empty optional, otherwise returns an empty.
        Parameters:
        json - JSON object
        name - name of the property
        Returns:
        non-empty optional if the property exists and is not null