Skip to content

Commit

Permalink
Enhancement: Encode JSON with JSON_PRETTY_PRINT flag
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 27, 2022
1 parent bff2903 commit 0e7fb9b
Show file tree
Hide file tree
Showing 63 changed files with 1,095 additions and 62 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For a full diff see [`3.0.0...main`][3.0.0...main].
- Dropped support for PHP 7.4 ([#757]), by [@localheinz]
- Required `ergebnis/json-schema-validator:^4.0.0` ([#771]), by [@localheinz]
- Allowed configuring the `Normalizer\SchemaNormalizer` to exclude properties from being sorted ([#774]), by [@localheinz]
- Adjusted `Vendor\Composer\BinNormalizer`, `Vendor\Composer\PackageHashNormalizer`, `Vendor\Composer\VersionConstraintNormalizer`, and `SchemaNormalizer` to encode JSON with `JSON_PRETTY_PRINT` flag ([#795]), by [@localheinz]

### Fixed

Expand Down Expand Up @@ -546,6 +547,7 @@ For a full diff see [`5d8b3e2...0.1.0`][5d8b3e2...0.1.0].
[#781]: https://github.com/ergebnis/json-normalizer/pull/781
[#793]: https://github.com/ergebnis/json-normalizer/pull/793
[#794]: https://github.com/ergebnis/json-normalizer/pull/794
[#795]: https://github.com/ergebnis/json-normalizer/pull/795

[@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(0);
return new self(\JSON_PRETTY_PRINT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
{"foo":{},"bar":{"baz":{"qux":"quux","quuz":"corge"},"grault":{"fred":"plugh","garply":"waldo"}}}
{
"foo": {},
"bar": {
"baz": {
"qux": "quux",
"quuz": "corge"
},
"grault": {
"fred": "plugh",
"garply": "waldo"
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
{"foo":{},"bar":{"baz":{"qux":"quux","quuz":"corge"},"grault":{"fred":"plugh","garply":"waldo"}},"thud":"xyzzy"}
{
"foo": {},
"bar": {
"baz": {
"qux": "quux",
"quuz": "corge"
},
"grault": {
"fred": "plugh",
"garply": "waldo"
}
},
"thud": "xyzzy"
}
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
{"bar":{"baz":{"qux":"quux","quuz":"corge"},"grault":{"fred":"plugh","garply":"waldo"}},"foo":{}}
{
"bar": {
"baz": {
"qux": "quux",
"quuz": "corge"
},
"grault": {
"fred": "plugh",
"garply": "waldo"
}
},
"foo": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
{"bar":[{"foo":9000,"bar":["foo","bar","baz"]},{"foo":9001}],"foo":"bar"}
{
"bar": [
{
"foo": 9000,
"bar": [
"foo",
"bar",
"baz"
]
},
{
"foo": 9001
}
],
"foo": "bar"
}
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
[{"type":"Website","url":"https:\/\/localheinz.com"},"https:\/\/github.com\/localheinz",{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]
[
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
"https:\/\/github.com\/localheinz",
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
[{"type":"Website","url":"https:\/\/localheinz.com"},"https:\/\/github.com\/localheinz",{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]
[
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
"https:\/\/github.com\/localheinz",
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
[{"type":"Website","url":"https:\/\/localheinz.com"},"https:\/\/github.com\/localheinz",{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]
[
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
"https:\/\/github.com\/localheinz",
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
[{"type":"Website","url":"https:\/\/localheinz.com"},"https:\/\/github.com\/localheinz",{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]
[
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
"https:\/\/github.com\/localheinz",
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
[{"type":"Website","url":"https:\/\/localheinz.com"},{"type":"GitHub","url":"https:\/\/github.com\/localheinz"},{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]
[
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
{
"type": "GitHub",
"url": "https:\/\/github.com\/localheinz"
},
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
["foo","bar","baz"]
[
"foo",
"bar",
"baz"
]
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
[9001,false,null,"Andreas M\u00f6ller",{"type":"Website","url":"https:\/\/localheinz.com"}]
[
9001,
false,
null,
"Andreas M\u00f6ller",
{
"type": "Website",
"url": "https:\/\/localheinz.com"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
["foo","bar","baz"]
[
"foo",
"bar",
"baz"
]
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
["foo","bar","baz"]
[
"foo",
"bar",
"baz"
]
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
[9001,false,null,"Andreas M\u00f6ller",{"type":"Website","url":"https:\/\/localheinz.com"}]
[
9001,
false,
null,
"Andreas M\u00f6ller",
{
"type": "Website",
"url": "https:\/\/localheinz.com"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
[{"baz":9000},{"baz":9001}]
[
{
"baz": 9000
},
{
"baz": 9001
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
["foo","bar","baz",{"baz":"qux","foo":"bar"}]
[
"foo",
"bar",
"baz",
{
"baz": "qux",
"foo": "bar"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{"name":"Andreas M\u00f6ller","urls":["https:\/\/localheinz.com","https:\/\/github.com\/localheinz","https:\/\/twitter.com\/localheinz"]}
{
"name": "Andreas M\u00f6ller",
"urls": [
"https:\/\/localheinz.com",
"https:\/\/github.com\/localheinz",
"https:\/\/twitter.com\/localheinz"
]
}
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
{"name":"Andreas M\u00f6ller","urls":["https:\/\/localheinz.com","https:\/\/github.com\/localheinz","https:\/\/twitter.com\/localheinz"]}
{
"name": "Andreas M\u00f6ller",
"urls": [
"https:\/\/localheinz.com",
"https:\/\/github.com\/localheinz",
"https:\/\/twitter.com\/localheinz"
]
}
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
{"name":"Andreas M\u00f6ller","urls":[{"type":"Website","url":"https:\/\/localheinz.com"},{"type":"GitHub","url":"https:\/\/github.com\/localheinz"},{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]}
{
"name": "Andreas M\u00f6ller",
"urls": [
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
{
"type": "GitHub",
"url": "https:\/\/github.com\/localheinz"
},
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
}
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
{"name":"Andreas M\u00f6ller","urls":[{"type":"Website","url":"https:\/\/localheinz.com"},{"type":"GitHub","url":"https:\/\/github.com\/localheinz"},{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]}
{
"name": "Andreas M\u00f6ller",
"urls": [
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
{
"type": "GitHub",
"url": "https:\/\/github.com\/localheinz"
},
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
}
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{"name":"Andreas M\u00f6ller","url-github":"https:\/\/github.com\/localheinz","url-twitter":"https:\/\/twitter.com\/localheinz","url-website":"https:\/\/localheinz.com"}
{
"name": "Andreas M\u00f6ller",
"url-github": "https:\/\/github.com\/localheinz",
"url-twitter": "https:\/\/twitter.com\/localheinz",
"url-website": "https:\/\/localheinz.com"
}
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"bar":[{"baz":9000},{"baz":9001}],"foo":"hello"}
{
"bar": [
{
"baz": 9000
},
{
"baz": 9001
}
],
"foo": "hello"
}
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
{"name":"Andreas M\u00f6ller","urls":[{"type":"Website","url":"https:\/\/localheinz.com"},{"type":"GitHub","url":"https:\/\/github.com\/localheinz"},{"type":"Twitter","url":"https:\/\/twitter.com\/localheinz"}]}
{
"name": "Andreas M\u00f6ller",
"urls": [
{
"type": "Website",
"url": "https:\/\/localheinz.com"
},
{
"type": "GitHub",
"url": "https:\/\/github.com\/localheinz"
},
{
"type": "Twitter",
"url": "https:\/\/twitter.com\/localheinz"
}
]
}
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{"name":"Andreas M\u00f6ller","url-github":"https:\/\/github.com\/localheinz","url-twitter":"https:\/\/twitter.com\/localheinz","url-website":"https:\/\/localheinz.com"}
{
"name": "Andreas M\u00f6ller",
"url-github": "https:\/\/github.com\/localheinz",
"url-twitter": "https:\/\/twitter.com\/localheinz",
"url-website": "https:\/\/localheinz.com"
}
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"bar":[{"baz":9000},{"baz":9001}],"foo":"hello"}
{
"bar": [
{
"baz": 9000
},
{
"baz": 9001
}
],
"foo": "hello"
}
Loading

0 comments on commit 0e7fb9b

Please sign in to comment.