ovidigital/js-object-to-json

Handle trailing commas

Closed this issue · 2 comments

Could you please improve the package to handle this case?

<?php

include 'vendor/autoload.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);

var_dump($json);

The current output is string(14) "{"foo":"bar",}"

@kakaska sure, thank you for reporting this bug! Will take care of it asap

@kakaska this has been fixed in the latest release