File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -558,6 +558,29 @@ project's root directory:
558
558
If the given file path is out of the project directory, a ``null `` value
559
559
will be returned.
560
560
561
+ serialize
562
+ ~~~~~~~~~
563
+
564
+ .. code-block :: twig
565
+
566
+ {{ object|serialize(format = 'json', context = []) }}
567
+
568
+ ``object ``
569
+ **type **: ``mixed ``
570
+
571
+ ``format `` *(optional) *
572
+ **type **: ``string ``
573
+
574
+ ``context `` *(optional) *
575
+ **type **: ``array ``
576
+
577
+ .. versionadded :: 5.3
578
+
579
+ The ``serialize `` filter was introduced in Symfony 5.3.
580
+
581
+ Accepts any data that can be serialized by the :doc: `Serializer component </serializer >`
582
+ and returns a serialized string in the specified ``format ``.
583
+
561
584
.. _reference-twig-tags :
562
585
563
586
Tags
Original file line number Diff line number Diff line change @@ -41,6 +41,19 @@ you need it or it can be used in a controller::
41
41
}
42
42
}
43
43
44
+ Or you can use the ``serialize `` Twig filter in a template:
45
+
46
+ .. code-block :: twig
47
+
48
+ {{ object|serialize(format = 'json') }}
49
+
50
+ See the :doc: `twig reference </reference/twig_reference >` for
51
+ more information.
52
+
53
+ .. versionadded :: 5.3
54
+
55
+ A ``serialize `` filter was introduced in Symfony 5.3 that uses the Serializer component.
56
+
44
57
Adding Normalizers and Encoders
45
58
-------------------------------
46
59
You can’t perform that action at this time.
0 commit comments