Skip to content

Commit

Permalink
Enhancement: Encode JSON with JSON_PRESERVE_ZERO_FRACTION flag
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 27, 2022
1 parent c59d57a commit 71fc775
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For a full diff see [`3.0.0...main`][3.0.0...main].
- Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_PRETTY_PRINT` flag ([#795]), by [@localheinz]
- Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_UNESCAPED_SLASHES` flag ([#801]), by [@localheinz]
- Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_UNESCAPED_UNICODE` flag ([#802]), by [@localheinz]
- Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_PRESERVE_ZERO_FRACTION` flag ([#803]), by [@localheinz]

### Fixed

Expand Down Expand Up @@ -552,6 +553,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#795]: https://github.com/ergebnis/json-normalizer/pull/795
[#801]: https://github.com/ergebnis/json-normalizer/pull/801
[#802]: https://github.com/ergebnis/json-normalizer/pull/802
[#803]: https://github.com/ergebnis/json-normalizer/pull/803

[@BackEndTea]: https://github.com/BackEndTea
[@dependabot]: https://github.com/dependabot
Expand Down
2 changes: 1 addition & 1 deletion src/Format/JsonEncodeOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private function __construct(private int $value)

public static function default(): self
{
return new self(\JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
return new self(\JSON_PRESERVE_ZERO_FRACTION | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Format/JsonEncodeOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testDefaultReturnsJsonEncodeOptions(): void
{
$jsonEncodeOptions = Format\JsonEncodeOptions::default();

$expected = \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE;
$expected = \JSON_PRESERVE_ZERO_FRACTION | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE;

self::assertSame($expected, $jsonEncodeOptions->toInt());
}
Expand Down

0 comments on commit 71fc775

Please sign in to comment.