org.apache.felix.cm.json.io

## Class Configurations

- java.lang.Object
- - org.apache.felix.cm.json.io.Configurations

    public class Configurations
    extends Object

Factory class for JSON and configuration support

### Method Summary

All Methods Static Methods Concrete Methods
`static ConfigurationReader.Builder` `buildReader()` Get a builder to create a configuration reader
`static ConfigurationWriter.Builder` `buildWriter()` Get a builder to create a configuration writer
`static jakarta.json.JsonValue` `convertToJsonValue(Object value)` Convert an object to a JSON value.
`static Object` `convertToObject(jakarta.json.JsonValue value)` Convert a json value into an object.
`static Reader` `jsonCommentAwareReader(Reader reader)` Create a reader handling comments in JSON.
`static Hashtable<String,Object>` `newConfiguration()` Create a new map for configuration properties The returned map keeps the order of properties added and is using case-insensitive keys.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### buildReader

    public static ConfigurationReader.Builder buildReader()

Get a builder to create a configuration reader

Returns:
  A configuration reader builder

#### buildWriter

    public static ConfigurationWriter.Builder buildWriter()

Get a builder to create a configuration writer

Returns:
  A configuration writer builder

#### jsonCommentAwareReader

    public static Reader jsonCommentAwareReader(Reader reader)
                                         throws IOException

Create a reader handling comments in JSON. The reader tries to leave the original structure of the document untouched, meaning comments will be replace with spaces. Closing this reader will close the underlying reader.

Parameters:
  `reader` - Reader for the JSON
Returns:
  Reader for the pure JSON
Throws:
  `IOException` - If reading fails.

#### newConfiguration

    public static Hashtable<String,Object> newConfiguration()

Create a new map for configuration properties The returned map keeps the order of properties added and is using case-insensitive keys.

Returns:
  A new map

#### convertToObject

    public static Object convertToObject(jakarta.json.JsonValue value)

Convert a json value into an object. The resulting object is

- `null` : if the provided value is `null` or `ValueType#NULL`
- A Boolean : if the json value is a boolean
- A Long : if the json value contains an integral number
- A Double : if the json value contains a non integral number
- A String : for any other provided non array value
- A Boolean[] : if the provided value is an array of booleans
- A Long[] : if the provided value is an array of integral numbers
- A Double[] : if the provided value is an array of non integral numbers
- A String[] : for any other provided array value

Parameters:
  `value` - The json value
Returns:
  The object or `null` if the provided value is `null` or `ValueType#NULL`

#### convertToJsonValue

    public static jakarta.json.JsonValue convertToJsonValue(Object value)

Convert an object to a JSON value. The resulting value is:

- `JsonValue.NULL` : if the provided value is `null`
- `JsonValue.TRUE` or `JsonValue.FALSE` : if the provided value is Boolean.
- A JSON value of type `JsonValue.ValueType#NUMBER` : if the value is a Integer, Long, Float, Double, Byte, Short
- `JsonValue.ValueType#OBJECT` : if the value is a map
- `JsonValue.ValueType#ARRAY` : if the value is an array or a collection
- `JsonValue.ValueType#STRING` : otherwise, calling `toString()` on the value.

Parameters:
  `value` - The object
Returns:
  The JSON value.