# 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
```


---

# 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://nodebook.js.org/js/jsonotebook.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.
