skip to Main Content

Php – Symfony serializer with array of entities

I have 2 DTO objects and I need to convert json to it: class SomeDTO { public function __construct( #[SerializedName('some_property')] private string $someProperty, #[SerializedName('some_other_property')] private int $someOtherProperty, ) { } public function getSomeProperty(): string { return $this->someProperty; } public function…

VIEW QUESTION

JSON parse error: Cannot construct instance: no int/Int-argument constructor/factory method to deserialize from Number value

I am trying to insert user record using mysql database Customer.java @Entity @NoArgsConstructor @AllArgsConstructor @Data public class Customer { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String firstname; private String lastname; @Column(unique = true) private String email; @Column(nullable =…

VIEW QUESTION

How to set a JsonSerializerOptions globally for my httpClient.GetFromJsonAsync<T> calls

In my ASP.NET web API I have httpClient which call GetFromJsonAsync: var jsonSerializerOptions = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); await httpClient.GetFromJsonAsync<Item[]>(uri, jsonSerializerOptions); It is quite repetitive to add the jsonSerializerOptions parameter in all my GetFromJsonAsync calls…

VIEW QUESTION
Back To Top
Search