> For the complete documentation index, see [llms.txt](https://senselab.gitbook.io/senselab-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://senselab.gitbook.io/senselab-docs/vendor/colinodell/json5.md).

# JSON5 for PHP - JSON for Humans

[![Latest Version on Packagist](https://img.shields.io/packagist/v/colinodell/json5.svg?style=flat-square)](https://packagist.org/packages/colinodell/json5) [![PHP 8.0+](https://img.shields.io/packagist/php-v/colinodell/json5.svg?style=flat-square)](https://packagist.org/packages/colinodell/json5) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](/senselab-docs/vendor/colinodell/json5/license.md) [![Build Status](https://img.shields.io/github/actions/workflow/status/colinodell/json5/tests.yml?branch=main\&style=flat-square)](https://github.com/colinodell/json5/actions?query=workflow%3ATests+branch%3Amain) [![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/colinodell/json5.svg?style=flat-square)](https://scrutinizer-ci.com/g/colinodell/json5/code-structure/main/code-coverage) [![SensioLabs Insight](https://img.shields.io/symfony/i/grade/920abb3b-a7d0-431a-bb5a-9831d142690e?style=flat-square)](https://insight.symfony.com/projects/920abb3b-a7d0-431a-bb5a-9831d142690e) ![UTF-8 Compatible](https://img.shields.io/badge/utf--8-compatible-brightgreen.svg?style=flat-square) [![Total Downloads](https://img.shields.io/packagist/dt/colinodell/json5.svg?style=flat-square)](https://packagist.org/packages/colinodell/json5)

This library is a PHP fork of the [JSON5 reference implementation](https://github.com/json5/json5).

JSON5 is a JS-compatible extension to JSON which allows comments, trailing commas, single-quoted strings, and more:

```js
{
    foo: 'bar',
    while: true,

    this: 'is a \
multi-line string',

    // this is an inline comment
    here: 'is another', // inline comment

    /* this is a block comment
       that continues on another line */

    hex: 0xDEADbeef,
    half: .5,
    delta: +10,
    to: Infinity,   // and beyond!

    finally: [
        'some trailing commas',
    ],
}
```

[See the JSON5 website for additional examples and details](http://json5.org).

## Install

Via Composer

```bash
$ composer require colinodell/json5
```

## Usage

This package adds a `json5_decode()` function which is a drop-in replacement for PHP's built-in `json_decode()`:

```php
$json = file_get_contents('foo.json5');
$data = json5_decode($json);
```

It takes the same exact parameters in the same order. For more details on these, see the [PHP docs](http://php.net/manual/en/function.json-decode.php).

To achieve the best possible performance, it'll try parsing with PHP's native function (which usually fails fast) and then falls back to JSON5.

### Exceptions

This function will **always** throw a `SyntaxError` exception if parsing fails. This is a subclass of the new `\JsonException` introduced in PHP 7.3. Providing or omitting the `JSON_THROW_ON_ERROR` option will have no effect on this behavior.

## Binary / Executable

A binary/executable named `json5` is also provided for converting JSON5 to plain JSON via your terminal.

```
Usage: json5 [OPTIONS] [FILE]

  -h, --help  Shows help and usage information

  (Reading data from STDIN is not currently supported on Windows)
```

### Examples:

Converting a file named file.json5:

```bash
json5 file.json5
```

Converting a file and saving its output:

```bash
json5 file.json5 > file.json
```

Converting from STDIN:

```bash
echo -e "{hello: 'world!'}" | json5
```

Converting from STDIN and saving the output:

```bash
echo -e "{hello: 'world!'}" | json5 > output.json
```

## Change log

Please see [CHANGELOG](/senselab-docs/vendor/colinodell/json5/changelog.md) for more information on what has changed recently.

## Testing

```bash
$ composer test
```

## Contributing

Please see [CONTRIBUTING](https://github.com/jeremy-sud/Senselab_Core_API/blob/main/vendor/colinodell/json5/CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](https://github.com/jeremy-sud/Senselab_Core_API/blob/main/vendor/colinodell/json5/CODE_OF_CONDUCT.md) for details.

## Security

If you discover any security related issues, please email <colinodell@gmail.com> instead of using the issue tracker.

## Support

In addition to standard support, [consider a Tidelift Subscription for professional support and get alerted when new releases or security issues come out](https://tidelift.com/subscription/pkg/packagist-colinodell-json5?utm_source=packagist-colinodell-json5\&utm_medium=referral\&utm_campaign=readme).

## Credits

* [Colin O'Dell](https://github.com/colinodell)
* [Aseem Kishore](https://github.com/aseemk), [the JSON5 project](https://github.com/json5/json5), and [their contributors](https://github.com/json5/json5#credits)
* [All other contributors to this project](https://github.com/colinodell/json5/graphs/contributors)

## License

The MIT License (MIT). Please see [License File](/senselab-docs/vendor/colinodell/json5/license.md) for more information.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://senselab.gitbook.io/senselab-docs/vendor/colinodell/json5.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.
