-
Notifications
You must be signed in to change notification settings - Fork 152
Contract for JSON encoding/decoding #254
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
base: master
Are you sure you want to change the base?
Conversation
My previous #161 (comment) still applies: In a nutshell, I'm for alternative solution 1 - keep the Introducing a Using virtual types is even more complex. I find that solution harder to understand as I would need to search di.xml to seem which options are set for a given type. It also puts additional weight on developers because they have to understand virtual types, arguably one of the more complex areas of object manager configuration. Keeping things simpler is usually better. Personally I still will probably continue to use PHP native |
An interface might be useful for alternative implementations - such as JSON5 |
@navarr The point of using a known interchangeable serialization format like JSON is that external tooling besides Magento can use the data. It needs to be dependable. Switching to a different format like JSON5 would break all that. For example JSON5 doesn’t work with MySQL, Postgres, Mongo or other storage engines with JSON support. I think it’s not a good scenario. JSON and the other formats are standardized, so switching implementations will not change the interpretation of the data. Switching the format is a huge breaking change. |
design-documents/data-format/json.md
Outdated
Since we want to protect our platform from any possible security vulnerabilities related to the code we do not control and have expected implementation we propose to add new dedicated contract for JSON. | ||
|
||
``` php | ||
interface JsonEncoderInterface |
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.
I would like to add an ability to use it as viewModel in phtml files by extending \Magento\Framework\View\Element\Block\ArgumentInterface
. What do you think?
- review updates
I am with @Vinai and I think this discussion might be a good starting point for broadening it. The current Magento approach is to avoid adding to existing interfaces as this would break other implementations of said interface. Instead we are introducing a new interface and deprecate the old (it's really just replacing one way of breaking with a different one).
On balance I believe this is optimising for the wrong audience. I am convinced that there are more users of
I think we should take a look at the polices and approach so that we can end up with:
as that would create less work over all. |
@Vinai @fooman thank you for the feedback, your arguments were compelling enough and I updated the proposal. Now the proposal states:
|
Thanks for listening! |
Since I forgot about #161 and force-pushed to my
master
, creating new PR.Hopefully this PR will get the second wind 🙂
Problem
The use of JSON data format might be wider than just serialization and current
Magento\Framework\Serialize\Serializer\Json
does not cover all those needs.Solution
New contract for JSON encoding/decoding.
Requested Reviewers
@maghamed
@Vinai
@fooman
Related Discussion
#161
magento/magento-coding-standard#91