Class JSONConfiguration

All Implemented Interfaces:
Cloneable, Configuration, EventSource, FileBasedConfiguration, HierarchicalConfiguration<ImmutableNode>, ImmutableConfiguration, ImmutableHierarchicalConfiguration, FileBased, InputStreamSupport, SynchronizerSupport, InMemoryNodeModelSupport, NodeKeyResolver<ImmutableNode>, NodeModelSupport<ImmutableNode>

public class JSONConfiguration extends AbstractYAMLBasedConfiguration implements FileBasedConfiguration, InputStreamSupport

A specialized hierarchical configuration class that is able to parse JSON documents.

Since:
2.2
  • Field Details

    • mapper

      private final com.fasterxml.jackson.databind.ObjectMapper mapper
      The object mapper used by the JSONConfiguration.
    • type

      private final com.fasterxml.jackson.databind.type.MapType type
      The MapType used to convert types.
  • Constructor Details

    • JSONConfiguration

      public JSONConfiguration()
      Creates a new instance of JSONConfiguration.
    • JSONConfiguration

      public JSONConfiguration(HierarchicalConfiguration<ImmutableNode> c)
      Creates a new instance of JSONConfiguration as a copy of the specified configuration.
      Parameters:
      c - the configuration to be copied
  • Method Details

    • read

      public void read(Reader in) throws ConfigurationException
      Description copied from interface: FileBased
      Reads the content of this object from the given reader. Client code should not call this method directly, but use a FileHandler for reading data.
      Specified by:
      read in interface FileBased
      Parameters:
      in - the reader
      Throws:
      ConfigurationException - if a non-I/O related problem occurs, e.g. the data read does not have the expected format
    • write

      public void write(Writer out) throws ConfigurationException, IOException
      Description copied from interface: FileBased
      Writes the content of this object to the given writer. Client code should not call this method directly, but use a FileHandler for writing data.
      Specified by:
      write in interface FileBased
      Parameters:
      out - the writer
      Throws:
      ConfigurationException - if a non-I/O related problem occurs, e.g. the data read does not have the expected format
      IOException - if an I/O error occurs.
    • read

      public void read(InputStream in) throws ConfigurationException
      Loads the configuration from the given input stream.
      Specified by:
      read in interface InputStreamSupport
      Parameters:
      in - the input stream
      Throws:
      ConfigurationException - if an error occurs