ovidigital/js-object-to-json

PHP library to convert a JavaScript object string to JSON formatted string

Installs: 165 757

Dependents: 6

Suggesters: 0

Security: 0

Stars: 18

Watchers: 1

Forks: 10

Open Issues: 4

pkg:composer/ovidigital/js-object-to-json

1.1.4 2023-12-08 18:40 UTC

This package is auto-updated.

Last update: 2025-10-08 22:52:45 UTC


README

PHP library to convert a JavaScript object string to JSON formatted string

Latest Version Build Status codecov

Installation

composer require ovidigital/js-object-to-json

Usage

// 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 file for license rights and limitations.