Skip to content

[Serializer] Document the CsvEncoder and the YamlEncoder #7654

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions serializer/encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ You can add new encoders to a Serializer instance by using its second constructo
Built-in Encoders
-----------------

Two encoders are used in the example above:
The Serializer component provides built-in encoders:

* :class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder` to encode/decode XML
* :class:`Symfony\\Component\\Serializer\\Encoder\\CsvEncoder` to encode/decode CSV
* :class:`Symfony\\Component\\Serializer\\Encoder\\JsonEncoder` to encode/decode JSON
* :class:`Symfony\\Component\\Serializer\\Encoder\\XmlEncoder` to encode/decode XML
* :class:`Symfony\\Component\\Serializer\\Encoder\\YamlEncoder` to encode/decode Yaml

.. versionadded:: 3.2
The :class:`Symfony\\Component\\Serializer\\Encoder\\CsvEncoder` and the
:class:`Symfony\\Component\\Serializer\\Encoder\\YamlEncoder` were added in
Symfony 3.2.

The ``JsonEncoder``
~~~~~~~~~~~~~~~~~~~

The ``JsonEncoder`` is much simpler and is based on the PHP
:phpfunction:`json_encode` and :phpfunction:`json_decode` functions.

The ``XmlEncoder``
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -56,8 +69,7 @@ Be aware that this encoder will consider keys beginning with ``@`` as attributes
// <foo bar="value" />
// </response>

The ``JsonEncoder``
The ``YamlEncoder``
~~~~~~~~~~~~~~~~~~~

The ``JsonEncoder`` is much simpler and is based on the PHP
:phpfunction:`json_encode` and :phpfunction:`json_decode` functions.
This encoder requires the :doc:`Yaml Component </components/yaml>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a version added note for this one.