# API Overview

**Create a new JSON configuration file programmatically**

```javascript
JSONConfig = new path.to.JSONConfig()
    .setNullSupport( true )
    .setUseTimeServer( true )
    .setAdminPassword( 'myPass' )
    .addCFMapping( '/foo', '/bar' )
    .write();
```

**Read an existing JSON configuration file**

```javascript
JSONConfig = new path.to.JSONConfig()
    .read( 'test.json' );
```

**Read an existing Lucee 4 server configuration file**

```javascript
lucee4ServerConfig = new path.to.Lucee4ServerConfig()
    .setCFHomePath( expandPath( '/path/to/lucee-server' ) )
    .read();

writeDump( lucee4ServerConfig.getMemento() );
```

**Read an existing JSON config file and load into a Lucee 5 web context**

```javascript
JSONConfig = new path.to.JSONConfig()
    .read( expandPath( '.CFConfig.json' ) );

new path.to.Lucee4WebConfig()
    .setMemento( JSONConfig.getMemento() )        
    .write( expandPath( 'WEB-INF/lucee/' ) );
```

### Notes

The `JSONConfig` will read/write to a JSON file called `.CFConfig.json` by default in the home directory you specify. You can alternatively specify a full path to a JSON file to change the name.

The Lucee 4 and Lucee 5 *web* components expect the `CFHomePath` to be the folder containing the `lucee-web.xml.cfm` file.\
An example would be:

```
<webroot>/WEB-INF/lucee/
```

The Lucee 4 and Lucee 5 *server* components expect the `CFHomePath` to be the `lucee-server` folder containing the `/context/lucee-server.xml` file.\
An example would be:

```
/opt/lucee/lib/lucee-server/
```

The Adobe components expect the `CFHomePath` to be the `cfusion` folder that contains the `lib/neo-runtime.xml` file.\
An example would be:

```
C:/ColdFusion11/cfusion/
```

The code in this library has only been tested on Lucee and likely doesn't work on Adobe ColdFusion. If anyone wants to make it compatible, feel free to try by beware of tons of use of the Elvis operator, reliance on sorted JSON structs, and some specific WDDX behavior.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cfconfig.ortusbooks.com/using-the-services/api-overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
