-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
JsonNormalizer
accepting json_encode
flags
#512
Conversation
2f321fd
to
5ccbaad
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This allows the JSON normalizer to accept some `JSON_*` constant options to be passed to `json_encode` via `flags` option. Signed-off-by: Maximilian Bösing <[email protected]>
Signed-off-by: Maximilian Bösing <[email protected]>
5ccbaad
to
e0eec68
Compare
Signed-off-by: Maximilian Bösing <[email protected]>
FYI: This adds additional time to the static analysis checks due to the |
This annotation leads to severe performance issues when running PHPStan analysis, also this annotation does not work well with PHPStan, therefore we prefer to avoid it.
Also makes the property private, we can force-access its value in tests where needed.
This class is internal and always instantiated by `JsonNormalizer` which already filters the bitmask.
@boesing excellent work, thank you for the contribution! I pushed some changes, I'll let you review them and comment if needed. When it's ready, let's ship it! 🚀 |
); | ||
|
||
// `$lowerManhattanAsJson` is a valid JSON string representing the data: | ||
// {"longitude":"40.7128","latitude":-74.0000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, somehow the longitude got string here. need to change this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
src/Normalizer/JsonNormalizer.php
Outdated
* ); | ||
* | ||
* // `$lowerManhattanAsJson` is a valid JSON string representing the data: | ||
* // {"longitude":"40.7128","latitude":-74.0000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
longitude shouldnt be string here as well
@boesing just updated after #476 (comment) Waiting for your review before merging! |
LGTM! Thanks for talking over. |
Thank you for this excellent contribution @boesing! |
As discussed in #476, this PR introduces a new
JsonNormalizer#withOptions
method accepting the followingJSON_*
constant values as an integer bitmask:JSON_HEX_QUOT
JSON_HEX_TAG
JSON_HEX_AMP
JSON_HEX_APOS
JSON_INVALID_UTF8_IGNORE
JSON_INVALID_UTF8_SUBSTITUTE
JSON_NUMERIC_CHECK
JSON_PRESERVE_ZERO_FRACTION
JSON_UNESCAPED_LINE_TERMINATORS
JSON_UNESCAPED_SLASHES
JSON_UNESCAPED_UNICODE
Since we should always enable
JSON_THROW_ON_ERROR
, I haven't added that one to the possible constants as it is enabled by-default.Closes #476