composer require ovidigital/js-object-to-json
// 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);
Feel free to submit a pull request or create an issue.
This project is licensed under the terms of the MIT license.
Check the LICENSE.md file for license rights and limitations.