Questions tagged [jmsserializerbundle]

A bundle for the Symfony 2-framework that allows you to serialize objects into a variety of output formats (such as YAML, XML or JSON).

JMSSerializerBundle is a bundle for the Symfony 2-framework, but can also be incorporated as a standalone component. It allows you to serialize your objects into a requested output format such as JSON, XML, or YAML, and vice versa. It provides you with a rich toolset which empowers you to adapt the output to your specific needs.

Built-in features include:

  • (de-)serialize object graphs of any complexity including circular references
  • supports many built-in PHP types (such as dates)
  • integrates with Doctrine ORM, et. al.
  • supports versioning, e.g. for APIs
  • configurable via PHP, XML, YAML, or annotations

JMSSerializerBundle is created by Johannes Schmitt, and available on GitHub as well as on jmsyst.com/bundles

475 questions
49
votes
1 answer

How to create a good hypermedia format using JMSSerializerBundle?

Lets say I want to create an XML-response that will looks something like the following: 1234 Red Stapler
PatrikAkerstrand
  • 45,315
  • 11
  • 79
  • 94
40
votes
6 answers

Add extra fields using JMS Serializer bundle

I've an entity I usually serialize using the JMS Serializer bundle. I have to add to the serialization some fields that doesn't reside in the entity itself but are gathered with some db queries. My idea was to create a custom object, fill the fields…
alex88
  • 4,788
  • 4
  • 39
  • 60
38
votes
3 answers

How to show null value in JSON in FOS Rest Bundle with JMS Serializer?

I had a read through this : https://github.com/schmittjoh/serializer/issues/77 but did not find any way to serialize null values in JSON for FOS Rest bundle with JMS serializer (meaning just show the key of the Doctrine object even if its null). I…
Geshan
  • 1,141
  • 2
  • 11
  • 21
38
votes
6 answers

JMSSerializer stand alone - Annotation does not exist, or cannot be auto-loaded

I am attempting to use JMSSerializer as a stand alone library to map JSON responses from an API to my model classes and am running into some issues. Executing the following code results in an exception:
Josh J
  • 6,813
  • 3
  • 25
  • 47
26
votes
2 answers

Serialize Doctrine array containing objects using inheritance

Problem: When serializing a collection of Doctrine enitities the collection will still have 2 items though the items are empty. Background: I have a few entities which extends each other B extends A and C extends B. In the entity Test I have an…
Roel Veldhuizen
  • 4,613
  • 8
  • 44
  • 78
26
votes
6 answers

Serializing Entity Relation only to Id with JMS Serializer

I'm trying to serialize a entity relation with JMS Serializer. Here is the Entity: class Ad { /** * @Type("string") * @Groups({"manage"}) * * @var string */ private $description; /** *…
escrichov
  • 559
  • 2
  • 6
  • 14
25
votes
2 answers

JMSSerializerBundle. no control over third party meta data

I have two entities I wish to serialize with the JMSSerializerBundle. The Music Entity has a mapping-file with exclusion_policy: NONE. The Music entity has a field of the entity User from FOSUserBundle. The User entity has a mapping-file with…
tolgap
  • 9,629
  • 10
  • 51
  • 65
23
votes
3 answers

jms serializer performance issue

I'm using the JMS Serializer. And I found out that the performance is really bad when I use big data. I've the following object structure displayed as an array: $jsonData = array( 'message' => 'this is a nice message', 'data' => array( …
Wolf-Tech
  • 1,259
  • 3
  • 18
  • 38
22
votes
6 answers

Symfony - Deserialize json to an array of entities

I have a json object that I received by making a get API call. I make this call to receive a list of objects. It's a list of post... So I have an array of Post Objects. Here the output : { "total":2, "data":[ { "id":2, …
manonthemoon
  • 2,611
  • 8
  • 26
  • 40
18
votes
1 answer

JMSSerializer deserializing collection

I have a problem with deserializing serialized collection of doctrine collections. Couldn't find docs about that and any topics and I'm new with JMSSerializer. When I try deserialize with: $collection =…
mrMantir
  • 2,285
  • 1
  • 17
  • 20
16
votes
5 answers

Disable Doctrine 2 lazy loading when using JMS Serializer?

Im using Doctrine 2 ORM in my Zend project and need to serialize my Entities to JSON in several cases. ATM i use the Querybuilder and join all tables i need. But my serializer causes doctrine to lazy load every associated Entity which results in…
Christian Huber
  • 828
  • 1
  • 5
  • 20
12
votes
2 answers

Why does JMS Serializer ignore mappings for nested collections?

I have entities in a OneToMany relation: Forecast -> has many -> Brick(s) I've created serialization mappings for each in Resources/config/serializer/Entity.xxx.yml where xxx is entity name. Each entity has exclusion policy set to ALL and some of…
ioleo
  • 4,697
  • 6
  • 48
  • 60
11
votes
2 answers

Deserialize array of object using jms/serializer

I want to deserialize something like this: [ { "id": 42 }, { "id": 43 } ] Any idea how to do this?
mykiwi
  • 1,671
  • 1
  • 19
  • 35
11
votes
5 answers

JMS Serializer: how to use camel case for properties

I'm using FOS Rest bundle and JMS Serializer to create a REST Api. The problem is I would like to keep the property names in the JSON response camel cased instead of using _. For example, I have a property called employeeIdentifier, by default that…
petekaner
  • 8,071
  • 5
  • 29
  • 52
11
votes
2 answers

JMS Serializer ignores mappings for Knp Paginator

I have problem with exclusion of some KNP Paginator properties with JMS Serializer. First, this is included in composer.json ... "jms/serializer-bundle": "~0.13", "knplabs/knp-paginator-bundle": "2.4.*@dev", ... I'm paginating CrmContacts entity…
nbucic
  • 163
  • 1
  • 10
1
2 3
31 32