|
@@ -71,6 +71,8 @@ Usage
|
|
|
De-/Serializing Objects
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
+::
|
|
|
+
|
|
|
$serializer = $container->get('serializer');
|
|
|
$serializer->serialize(new MyObject(), 'json');
|
|
|
$serializer->serialize(new MyObject(), 'xml');
|
|
@@ -294,6 +296,8 @@ Examples::
|
|
|
~~~~~~~~
|
|
|
This allows you to specify the name of the top-level element.
|
|
|
|
|
|
+::
|
|
|
+
|
|
|
<?php
|
|
|
|
|
|
use JMS\SerializerBundle\Annotation\XmlRoot;
|
|
@@ -304,7 +308,7 @@ This allows you to specify the name of the top-level element.
|
|
|
private $name = 'Johannes';
|
|
|
}
|
|
|
|
|
|
-Resulting XML:
|
|
|
+Resulting XML::
|
|
|
|
|
|
<user>
|
|
|
<name><![CDATA[Johannes]]></name>
|
|
@@ -315,6 +319,8 @@ Resulting XML:
|
|
|
This allows you to mark properties which should be set as attributes,
|
|
|
and not as child elements.
|
|
|
|
|
|
+::
|
|
|
+
|
|
|
<?php
|
|
|
|
|
|
use JMS\SerializerBundle\Annotation\XmlAttribute;
|
|
@@ -326,7 +332,7 @@ and not as child elements.
|
|
|
private $name = 'Johannes';
|
|
|
}
|
|
|
|
|
|
-Resulting XML:
|
|
|
+Resulting XML::
|
|
|
|
|
|
<result id="1">
|
|
|
<name><![CDATA[Johannes]]></name>
|
|
@@ -338,6 +344,8 @@ This allows you to define several properties of how arrays should be
|
|
|
serialized. This is very similar to @XmlMap, and should be used if the
|
|
|
keys of the array are not important.
|
|
|
|
|
|
+::
|
|
|
+
|
|
|
<?php
|
|
|
|
|
|
use JMS\SerializerBundle\Annotation\XmlList;
|
|
@@ -365,7 +373,7 @@ keys of the array are not important.
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Resulting XML:
|
|
|
+Resulting XML::
|
|
|
|
|
|
<post>
|
|
|
<comment>
|