Class Poco::Util::JSONConfiguration
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::Util

# class JSONConfiguration

Library: Util
Package: Util
Header: Poco/Util/JSONConfiguration.h

## Description

This configuration class extracts configuration properties from a JSON object. An XPath-like syntax for property names is supported to allow full access to the JSON object.

Given the following JSON object as an example: {

    "config" : {
       "prop1" : "value1",
       "prop2" : 10,
       "prop3" : [
         "element1",
         "element2"
       ],
       "prop4" : {
         "prop5" : false,
         "prop6" : null
       }
    }

} The following property names would be valid and would yield the shown values:

config.prop1 —> "value1" config.prop3[1] —> "element2" config.prop4.prop5 —> false

## Inheritance

Direct Base Classes: AbstractConfiguration

All Base Classes: Poco::RefCountedObject, AbstractConfiguration

## Member Summary

Member Functions: enumerate, getRaw, load, loadEmpty, removeRaw, save, setBool, setDouble, setInt, setRaw, setString

Inherited Functions: createView, duplicate, enableEvents, enumerate, eventsEnabled, expand, getBool, getDouble, getInt, getInt64, getRaw, getRawString, getString, getUInt, getUInt64, has, hasOption, hasProperty, keys, parseBool, parseInt, parseInt64, parseUInt, parseUInt64, referenceCount, release, remove, removeRaw, setBool, setDouble, setInt, setInt64, setRaw, setRawWithEvent, setString, setUInt, setUInt64

## Constructors

### JSONConfiguration

JSONConfiguration();

Creates an empty configuration

### JSONConfiguration

JSONConfiguration(
const std::string & path
);

Creates a configuration and loads the JSON structure from the given file

### JSONConfiguration

JSONConfiguration(
std::istream & istr
);

Creates a configuration and loads the JSON structure from the given stream

### JSONConfiguration

JSONConfiguration(
const JSON::Object::Ptr & object
);

Creates a configuration from the given JSON object

## Destructor

### ~JSONConfiguration

virtual ~JSONConfiguration();

Destructor

## Member Functions

### load

void load(
const std::string & path
);

Loads the configuration from the given file

### load

void load(
std::istream & istr
);

Loads the configuration from the given stream

### loadEmpty

void loadEmpty(
const std::string & root
);

Loads an empty object containing only a root object with the given name.

### removeRaw

virtual void removeRaw(
const std::string & key
);

See also: Poco::Util::AbstractConfiguration::removeRaw()

### save

void save(
std::ostream & ostr,
unsigned int indent = 2
) const;

Saves the configuration to the given stream

### setBool

virtual void setBool(
const std::string & key,
bool value
);

See also: Poco::Util::AbstractConfiguration::setBool()

### setDouble

virtual void setDouble(
const std::string & key,
double value
);

See also: Poco::Util::AbstractConfiguration::setDouble()

### setInt

virtual void setInt(
const std::string & key,
int value
);

See also: Poco::Util::AbstractConfiguration::setInt()

### setString

virtual void setString(
const std::string & key,
const std::string & value
);

See also: Poco::Util::AbstractConfiguration::setString()

### enumerate

void enumerate(
const std::string & key,
Keys & range
) const;

See also: Poco::Util::AbstractConfiguration::enumerate()

### getRaw

bool getRaw(
const std::string & key,
std::string & value
) const;

See also: Poco::Util::AbstractConfiguration::getRaw()

### setRaw

void setRaw(
const std::string & key,
const std::string & value
);

See also: Poco::Util::AbstractConfiguration::setRaw()