Class JsonSubstitutions


  • public final class JsonSubstitutions
    extends java.lang.Object
    Finds string set in a Node object string value and replaces them with a corresponding Node.

    Each key represents a string to search for, and each value represents what to replace the string with. A value can be any type of Node, allowing for strings to be changed to objects, arrays, etc. Partial string matches are not currently supported.

    For example, given the following values to replace:

    {"FOO": {"bar": "baz"}}

    and the following Node value:

    {"hello": "FOO", "baz": "do not replace FOO"},

    the resulting Node will become:

    {"hello": {"bar: "baz"}, "baz": "do not replace FOO"}.

    Notice that "do not replace FOO" was not modified because the entire string did not literally match the string "FOO".

    • Method Detail

      • create

        public static JsonSubstitutions create​(ObjectNode node)
        Creates a substitutions instance from an ObjectNode.
        Parameters:
        node - ObjectNode used to create the instance.
        Returns:
        Returns the created JsonSubstitutions.
      • create

        public static JsonSubstitutions create​(java.util.Map<java.lang.String,​Node> map)
        Creates a substitutions instance from a Map.
        Parameters:
        map - Map used to create the instance.
        Returns:
        Returns the created JsonSubstitutions.
      • apply

        public Node apply​(Node node)
        Replaces strings in the given node.
        Parameters:
        node - Node to update.
        Returns:
        Returns the updated node.