# JSONotebook

"JSONotebook" is a customized class used for JSON (JavaScript Object Notation) files.

## Usage

### Setup

```javascript
const Nodebook = require('nodejs-notebook');

const config = new Nodebook.JSONotebook('config');
```

**note(key, value)**

Properly notes a key and a value into JSON data. Can also replace existing values.

`key`:\
Represents the key to fetch the `value`. Can be anything.

`value`:\
The value that `key` is tied to. Can be anything.

```javascript
config.note('name', 'Alex');
// Sets "name" to "Alex"

config.note('name', 'Alexander');
// Name isn't "Alex" anymore, it is "Alexander"
```

**push(key, newkey)**

Pushes a value into an array.

&#x20;`key`:\
The key that represents the array.

{% hint style="warning" %}
The value tied to the key must be an **existing** array or it will not work
{% endhint %}

`newkey`:\
The value to push into the array. Can be anything.

```javascript
config.push('favorite_colors', 'blue');
// Adds "blue" to array "favorite_colors"
```

**fetch(key)**

Fetches a value based on the key.

`key`:\
The key that represents the value you want to get.

```javascript
const myname = config.fetch('name');
console.log(myname);
// logs "Alexander"
```

**erase(key)**

Erases an existing value from the JSON file.

`key`:\
The key that represents the value you want erased.

```javascript
config.erase('hate_letters');
// Array "hate_letters" does not exist anymore

config.erase('middlename');
// String "middlename" does not exist anymore
```

**toYML()**

Converts the JSON data to YML data.

```javascript
let yml = config.toYML();
console.log(yml.toString());
// logs the JSON data as YML data
```
