Questions tagged [jms-serializer]
Serializer is a library, that allows you to (de-)serialize data of any complexity. It supports XML, JSON, and YAML.
222
questions
0
votes
1
answer
29
views
JMS Service not pushing XML files to Queue. Stops processing in between and needed to restart the service to push the files further
There is a directory named /var/xyz/aa/clm/data/infiles/SenderJMS/CE/L3/ where number of XML files are stored after a process runs. These files contain data to be pushed to remote server through a JMS ...
0
votes
1
answer
135
views
Equivalance symfony/serializer "SerializedPath" for jms/serializer
I have this particular json to decode with jms/serializer:
{
"id": 42,
"attributes": {
"name": "toto",
"alternativeText": null
}
}
into:...
0
votes
0
answers
11
views
JMS Serialzer update to 3.x replacement for serializer->getMetadataFactory()
I have some legacy code here using serializer 1.x that needs to be updated to PHP8 - so to serialzer 3.x.
The problem is the old code uses> serializer->getMetadataFactory() to dynamically ...
0
votes
0
answers
100
views
Cannot override final class FormErrorHandler with JWT Serializer
Good morning all , I did a complete migration of my symfony 2.8 application to version 5.4. I am now at the unit testing stage.
but I have a little problem with one in running my tests. On the old ...
0
votes
1
answer
247
views
Change Symfony serializer order when extending models
I am working on a REST API with Symfony 5.4; PHP 7.4; using the default Symfony serializer. When I define a model extending from another, the properties of the child model are serialized before the ...
0
votes
1
answer
134
views
JMSSerializer > don't return null value and empty array
I want to serialize some object but don't return null values or empty array.
Here is my json:
{
"success": true,
"detail": {
"id": 588,
"label": null,
...
2
votes
3
answers
882
views
Automatically implementing JMS serialization for many php backed enums
Context
By using the JMS serializer library, I need to serialize/unserialize data which are internally represented by php backed enums.
What's the problem
I found a solution by using the ...
0
votes
0
answers
122
views
Try to update Sonata, have error with jms-serializer
I need to update my bundles for security reasons but when i try to do a composer update, i have a lot of problem with sonata.
First, SonataCore, sonataMedia and JMS-serializer disappear.
bundles.php
...
1
vote
1
answer
900
views
Symfony: how to add a serializer group on a Route depending on logged in user's roles
I'm using JMSSerializerBundle in my entities definition, and RestBundle's annotations in controllers.
I have an entity with public and admin-protected attributes, let's say
use JMS\Serializer\...
5
votes
0
answers
1k
views
Symfony serializer Virtual Property like JMS Expression Prop
I'm on a project currently using JMS Serializer in an API.
We use a lot of virtual properties - especially expression Prop in the serialization mapping.
App\Entity\MyEntity:
exclusion_policy: none
...
1
vote
1
answer
575
views
how can I make JMS/Serializer deserialize this property to object?
I have the following class
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Type;
/**
* @ExclusionPolicy("none")
*/...
0
votes
1
answer
188
views
Using JMS Serializer with PHPSpec testing case causes The annotation @JMS\Serializer\Annotation\Type does not exist, or could not be auto-loaded
I have a function to transform array into object.
public function transform(array $pickupPoints): array
{
return SerializerBuilder::create()
->setSerializationContextFactory(function () ...
1
vote
2
answers
2k
views
Deserialize single string property into object in symfony JMS PHP
Having PHP, Symfony 4.4, JMS Serializer and json payload (request body) as such:
{
"quantity": 1,
"product": {
"sku": "bla"
},
"myId": {
...
0
votes
0
answers
307
views
JMS\Serializer OBJECT_TO_POPULATE
Is it possible deserialize to an object with JMS\Serializer?
I don't see n option like the one Symfony Serializer has:
https://symfony.com/doc/current/components/serializer.html#deserializing-in-an-...
1
vote
1
answer
799
views
Symfony 5 NelmioDocsBundle and JMS Seralizer
Having a bit of trouble understanding the combo of tools in the title.
When I view my docs the model is empty:
That said I've tried a bunch of things including disabling jms which works but I want to ...
0
votes
1
answer
2k
views
How to serialize object as its own property (array) using JMS Serializer EventSubscriberInterface (php, symfony)
I need to serialize an object as its own property (it's type is array), I mean that the object has an array property books, and after transforming it I want to skip the books key, so the structure ...
0
votes
1
answer
158
views
Strange Offset between De- and Serialization of Datetime with JMS Serializer
I'm developing a scheduling app whose frontend communicates with the backend via UNIX-Timestamp-based time fields. The app has been used for almost a year in production, but suddenly, thank god only ...
6
votes
1
answer
4k
views
How to use inherited classes with API-Platform
I wish to use API-Platform to perform CRUD operations on object hierarchy classes. I found little written when using inherited classes with API-Platform and some but not much more when used with ...
0
votes
2
answers
2k
views
Symfony 5.2 Error: The directory "var/cache/dev/jms_serializer" does not exist
Symfony 5.2 with jms/serializer-bundle 3.7.0.
After symfony cache cleaning by command cache:clear on the next request I get an error:
The directory "var/cache/dev/jms_serializer" does not ...
0
votes
2
answers
321
views
Symfony5 JMS Serializer - model with calculated property without ORM annotation
I have model properties like this:
/**
* @ORM\Entity(repositoryClass=AssignmentRepository::class)
*/
class Assignment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type=&...
1
vote
0
answers
192
views
JMS deserialize part of an xml
I am trying to deserialize a complicated xml, and I only need a nested part of the xml not the whole part.
There is a simple example, what I'd like to do:
<foo>
<bar>
<user>
...
0
votes
1
answer
531
views
Default deserializeFormats for DateTime in JMS Serializer
I see default_format and default_timezone configs for deserializing datetime values but I don't see a config to specify a list of alternate formats. I would like for my API to accept timestamps with ...
0
votes
0
answers
108
views
JMSConnection serialization fail
Currently I'm building an application that reads messages (transactions in json) in a Kafka Topic and sends to IBM MQ at production. I'm having some trouble with serialization in the JMS classes and ...
1
vote
1
answer
734
views
How can I all errors show in json format in friendsofsymfony/rest-bundle v3
I want intercept all errors of Symfony after that show them in JSON.
In friendsofsymfony/rest-bundle v2 I can set parameters
fos_rest:
exception:
enabled: true
...
2
votes
0
answers
31
views
Is it possible to create a group dependency in JMS
Lets say I have following structure:
Article:
name
content
galleries: array of Gallery
Gallery:
name
description
media : array of Media
thumbnail: Media
Media:
name
file
Now when I am ...
0
votes
1
answer
359
views
symfony serializer jmsserializerbundle service name conflict
I have the following issue: I am working on a symfony (2.8) project which depends on the jmsserializerbundle (1.1).
When enabling the symfony-serializer alongside the jms-serializer package,
# app/...
1
vote
1
answer
1k
views
Symfony 3.4 JMS Serializer DoctrineObjectConstructor::__construct() expect ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given
Please help me , I am stuck here. I have recently upgraded Symfony version from 2.8 to Symfony 3.4 LTS version. All works fine except the Rest API end point where I extend the Sonata\UserBundle\...
3
votes
1
answer
771
views
Symfony + JMS Serializer: Deserializing a DateTime value returns current time also
I have the following annotation for the birthDate field:
/**
* @Serializer\SerializedName("birthDate")
* @Serializer\Type("DateTimeImmutable<'Y-m-d'>")
*/
public $birthDate;
...
0
votes
2
answers
1k
views
How configure JMSSerializer in Symfony to serialize custom class to/from int?
I am working on a Symfony 3.4 based web app project which uses JMSSerializer to serialize different custom classes to JSON to send this data to mobile apps.
How can I serialize/deserialize a custom ...
1
vote
1
answer
116
views
JMSSerializer hasData deprecated
I have an entity with relatives paths. If those links are serialized, I want to change them to an absolute path.
class EntityA
{
/**
* @var string
*
* @Serializer\Expose
* @...
0
votes
1
answer
868
views
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 ...
1
vote
0
answers
141
views
jms serializer @Exclude condition on class
My question is rather equal to Symfony2 - JMS Serializer - Exclude entity if getDeleted() is not null but the accepted answer offered a workaround and not an actual response and does not fit my ...
1
vote
0
answers
215
views
2 identical JMS listeners are implemented instead of the 1st. ActiveMQ And cannot transmit and receive the object
I am writing an application in Spring (I do not use Spring Boost). The application uses the JMS broker ActiveMQ.
Listener:
@Component
public class ReceiveMessage {
private HistoryService ...
2
votes
0
answers
3k
views
How to specify several object type within single property using Swagger and/or JMS serializer?
I use Swagger and JMS serializer and show built OpenAPI JSON using NelmioAPIDocBundle https://github.com/nelmio/NelmioApiDocBundle
I have an object with a property, which is an array, that might ...
0
votes
1
answer
934
views
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 ...
1
vote
2
answers
827
views
JMS Serializer perfomance issues with more than 10000 entries
Currently I'm building a PHP command that can update my ElasticSearch indices.
But, a big thing I've noticed is that serializing entities when my array holds more than 10000 of them is taking way ...
0
votes
0
answers
281
views
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)
*/
...
1
vote
0
answers
371
views
How to serialize an object "datetime" property into a "date" elasticsearch type, not "text"
I am creating a website using Symfony 4.
Visitors will need to search through thousands of articles ordered by "dynamic_date". I use Elasticsearch 6.7, FOSElasticaBundle and JMS Serializer to index "...
0
votes
1
answer
1k
views
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,...
0
votes
1
answer
1k
views
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\...
2
votes
1
answer
300
views
Deserialize XML element which could have different namespaces
I'm trying to get element from XML under one variable, where I'm having the same xml tree, but with another xml namespace prefix.
I've got a lot similar elements, and that would be annoying to write ...
0
votes
1
answer
590
views
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)
->...
0
votes
1
answer
2k
views
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 {
/**
*...
1
vote
1
answer
178
views
What is the difference between the serializer virtualProperty and the accessor?
Per the Serializer virtualProperty documentation
Note: This only works for serialization and is completely ignored
during deserialization.
Other than this limitation, what is the difference ...
1
vote
0
answers
49
views
Many to Many Self Referencing Search
I have a "Many to Many Self Referencing" entity and need to do a search for the elements parents are children.
For example
{
"id": 58,
"name": "DVD & Home Theater",
"parent": {
...
1
vote
1
answer
942
views
How can one expose the discriminator in the serialized output?
How can one expose the discriminator in the serialized output?
The following was adapted from this example and adjusted by the XML reference.
My entities are:
namespace Fully\Qualified;
abstract ...
3
votes
0
answers
556
views
How to add default namespace to (de)serialized XML via JMS/Serializer?
I am using JMS/Serializer (in Laravel). I have generated *.yml files and *.php classes for my serializer. There are xml_root_name and xml_root_namespace defined in my yml file:
App\Test\MyApp\...
3
votes
2
answers
2k
views
JMS Serializer: overriding default naming strategy in symfony 4 has no effect
I found this thread proposing a neat way of overriding globally the default naming strategy in config.yml
but this is for symfony 3 and I am on symfony 4 so I added the line to my config > ...
1
vote
1
answer
297
views
JMSSerializer events do not work for concrete types
I am trying to create an EventSubscriber for different serialization events using Symfony 3.4.21, JMSSerializer 2.1.0 and JMSSerializerBundle 3.0.0.
Problem is, that the subscribers only work if ...
0
votes
0
answers
192
views
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 (...