Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keys of just 1 char gives error #1

Open
emandtf opened this issue May 23, 2024 · 0 comments
Open

Keys of just 1 char gives error #1

emandtf opened this issue May 23, 2024 · 0 comments

Comments

@emandtf
Copy link

emandtf commented May 23, 2024

I have a very big JSON and some key:value pairs are similar to this:
['p' => '1234']

but this library gives an error because the Key is just 1 char:
return Compressor::create()->compress(['p' => '1234'])->toJson();

If the Key becomes "pp" it works fine.

The error is located here:

php-compress-json / src / DataTypes / JsonString.php : 10

in this method:

public static function encodeString(string $str): string {
$prefix = $str[0] . $str[1]; <-- HERE BECAUSE IF THE KEY IS JUST "p" THE INDEX [1] DOESN'T EXISTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant