Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Improve serialization example #2402

Closed
wants to merge 1 commit into from

5 participants

@tvlooy

Improve serialization example

Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets #2225
@tvlooy tvlooy Improve serialization example
Improve serialization example

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | yes
| Applies to    | all
| Fixed tickets | #2225
f529afb
@tvlooy tvlooy referenced this pull request in schmittjoh/serializer
Merged

Improve serialization example #71

@stof

new docs: yes ? this is not adding new doc but only fixing existing one.

@tvlooy

I saw it as an extension and thereby something new. Changed now.

@WouterJ
Collaborator

It doesn't make much sense. I also think it's a new docs.

@tvlooy

Well, does it matter?

@weaverryan
Collaborator

Awesome job Tom - another PR merged, issue closed.

I've patched this into the 2.0 branch at sha: 1a8d0dc

Thanks!

@weaverryan weaverryan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2013
  1. @tvlooy

    Improve serialization example

    tvlooy authored
    Improve serialization example
    
    | Q             | A
    | ------------- | ---
    | Doc fix?      | yes
    | New docs?     | yes
    | Applies to    | all
    | Fixed tickets | #2225
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 components/serializer.rst
View
6 components/serializer.rst
@@ -90,7 +90,11 @@ use the Serializer service created before::
$person->setName('foo');
$person->setAge(99);
- $serializer->serialize($person, 'json'); // Output: {"name":"foo","age":99}
+ $jsonContent = $serializer->serialize($person, 'json');
+
+ // $jsonContent contains {"name":"foo","age":99}
+
+ echo $jsonContent; // or return it in a Response
The first parameter of the :method:`Symfony\\Component\\Serializer\\Serializer::serialize`
is the object to be serialized and the second is used to choose the proper encoder,
Something went wrong with that request. Please try again.