Questions tagged [jms-serializer]

Serializer is a library, that allows you to (de-)serialize data of any complexity. It supports XML, JSON, and YAML.

Serializer is a library, that allows you to (de-)serialize data of any complexity. Currently, it supports XML, JSON, and YAML.

Website: http://jmsyst.com/libs/serializer

It also provides you with a rich tool-set to adapt the output to your specific needs.

Built-in features include:

  • (De-)serialize data of any complexity; circular references are handled gracefully.
  • 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 Doctrine Annotations
222 questions
0
votes
1 answer

Using a different naming strategy for each class with JMS and Symfony 3.4

Hello dear Stackoverflow community, I have 2 PHP class (considered as DTO) that I'm using to set the body of my HTTP calls. Each DTO is used for a different API with different naming strategies (one is using camelCase and the other one is using…
Ga3tan
  • 85
  • 1
  • 12
0
votes
1 answer

JMS Serializer expressions not working in virtual property with Symfony 3.4

I recently deep dived into JMS Serializer and although I like it how the package makes a lot of things convenient for the developer in serialisation/deserialisation but there is a major lack of documentation around available options in the package.…
Aman
  • 439
  • 5
  • 15
0
votes
0 answers

Symfony JMS Serializer - Endpoint for uploaded files

How can I upload a file using JMS Serializer? Now I'm getting Notice: Array to string conversion App\Entity\Answer /** * @Type("string") * @ORM\Column(type="string", length=255, nullable=true) */ private…
0
votes
1 answer

Mixing Accessor and SkipWhenEmpty in JMS Serializer

I'm using JMS serializer in a project, and I'm struggling with one thing. I'm using the @Accessor annotation (On a DateTime property) to echo only the date without the time. But on some of my objects, I won't have any information and I don't want…
Marc Brillault
  • 1,902
  • 4
  • 21
  • 41
0
votes
1 answer

problem with converting a entity to json using jms_serializer - Symfony 4

i'm trying to make an api to return a json with symfony 4 i create a entity and it's work fine but it do not convert data for database to json so the Serializer from "Symfony\Component\Serializer\Serializer" give me error serialization for the…
Rami
  • 37
  • 6
0
votes
1 answer

Override JMS Serializer global camelCase

I wish to default to outputting camel case names, and this answer provides an excellent solution. $serializer= \JMS\Serializer\SerializerBuilder::create() ->setDebug(true) ->addMetadataDir(APP_ROOT.'/config/serializer') …
user1032531
  • 24,767
  • 68
  • 217
  • 387
0
votes
1 answer

Symfony - How to deserialize with default values?

I'm starting to learn Symfony 4. I want to deserialize datas from json data. (I'm using JMSSerializer) This is my context : I have a Customer entity in src/App/Entity class Customer { /** * * @ORM\Id *…
quokka-web
  • 104
  • 8
0
votes
0 answers

JMS serializer - how to ignore (not exclude) property (already json)

i have an object that stores a json string in one of the properties. And i don't want it to be serialized again. Is there a reasonable way to ignore it ? PostSerialize event might be an option (revert it back), but that's dirty. I'd prefer a cleaner…
0
votes
1 answer

Symfony 4 + JMS Serializer - Internal Server Error

I have a problem with serialization data. I have two entities, which are connection relation. These are my entities: Task.php use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as JMS; /** * @ORM\Entity */ class Task { /** * …
Jotter
  • 45
  • 8
0
votes
0 answers

Use a repository with JMS serializer

I have a Symfony 3.4 projet with a REST api. I use JMS serializer. I have a entity User and I have a route /api/user which return the user id, name , ... I also have a entity badges which has a relation many to many with user (so a user_badge…
0
votes
1 answer

JMS Serializer: how to propagate group exclusion for properties without adding annotations everywhere?

I am building an API with Symfony and JMS Serializer (via FOSRestundle) that exposes trees. I've created an Tree entity that contains an id, a title and the root node of the tree. I've created a Node entity too, containg the chaining between…
moudug
  • 209
  • 1
  • 3
  • 13
0
votes
1 answer

JMS Serializer does not apply formatting to newly created objects

When getting an object from an API, I receive a properly serialized Course object. "startDate": "2018-05-21", But when I create a new object and try to return it, the formatting is not applied. "startDate": "2019-02-01T02:37:02+00:00", Even if I…
RonnyKnoxville
  • 6,166
  • 10
  • 46
  • 75
0
votes
1 answer

Apply separately many JMS serialization groups on the same function

I'm looking for a feature with jms_serliazer. Ok let me explain, suppose we have a function getArticlesAction(), and a query param called group that gonna represent the group serialization name. So, after getting the name of serialization group…
famas23
  • 2,072
  • 4
  • 17
  • 53
0
votes
0 answers

JmsSerializer - different serialization logic for object depending on context

I need to create different object views depending on context. For example, I need to serialize object for MySQL and ElasticSearch. For ElasticSearch I need to place word "def" instead of empty string. I also want the objects to be deserialized…
Serhii Smirnov
  • 1,338
  • 1
  • 16
  • 24