https://github.com/ovidigital/js-object-to-json
PHP library to convert a JavaScript object string to JSON format
https://github.com/ovidigital/js-object-to-json
convert javascript json object
Last synced: about 1 year ago
JSON representation
PHP library to convert a JavaScript object string to JSON format
- Host: GitHub
- URL: https://github.com/ovidigital/js-object-to-json
- Owner: ovidigital
- License: mit
- Created: 2020-04-20T13:30:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T18:42:02.000Z (over 2 years ago)
- Last Synced: 2025-04-02T19:04:30.832Z (about 1 year ago)
- Topics: convert, javascript, json, object
- Language: PHP
- Size: 36.1 KB
- Stars: 18
- Watchers: 1
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ovidigital/js-object-to-json
###### PHP library to convert a JavaScript object string to JSON formatted string
[](https://github.com/ovidigital/js-object-to-json/releases)
[](https://github.com/ovidigital/js-object-to-json/actions/workflows/ci.yml?query=branch%3Amaster)
[](https://codecov.io/gh/ovidigital/js-object-to-json)
## Installation
```bash
composer require ovidigital/js-object-to-json
```
## Usage
```php
// A variable containing a JavaScript object as a string
$jsObjectString = "{ foo: 'bar' }";
// Convert the JavaScript object to JSON format
$json = \OviDigital\JsObjectToJson\JsConverter::convertToJson($jsObjectString);
// Alternatively convert the JavaScript object to a PHP array
$phpArray = \OviDigital\JsObjectToJson\JsConverter::convertToArray($jsObjectString);
```
## Contributing
Feel free to submit a pull request or create an issue.
## License
This project is licensed under the terms of the MIT license.
Check the [LICENSE.md](LICENSE.md) file for license rights and limitations.