How to serialize a class with Newtonsoft.Json.JsonConvert.SerializeObject to change empty List to null variable

How to serialize a class with Newtonsoft.Json.JsonConvert.SerializeObject to change empty List to null variable my result from serialization {“images”:[]} or {“images”:{}} and would like to get {“images”:null} my simple class public class Images { [JsonProperty(“images”, Required = Required.Always, NullValueHandling = NullValueHandling.Include)] public Images() { Parameters = new Parameters(); **// I know I could not initiate…

Could not write JSON and .JsonMappingException: Infinite recursion (StackOverflowError) error

I am getting StackOverflow recursion error when I run query in Postman . Here is the model classes : @Entity public class UserWallet { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @NotNull private String userName; private String firstName; private String lastName; private String email; @Temporal(TemporalType.DATE) private Date createdDate; @OneToMany(mappedBy = “userAccount”, fetch = FetchType.EAGER) private Set <Transaction>…

Export json to xlsx in angular

I’m trying to export my json to xlsx. I’m able to export it but, not getting the right format in excel file. Here is my code : downloadFile() { let Obj = { “data”: [12,123], “date”: [“2018-10-10″,”2018-02-10”] } const items = []; items[‘data’] = Obj.data; items[‘date’] = Obj.date; const header = Object.keys(items); let csv; header.map((data)=>{…

How to continue parsing JSON, if JSON has errors (Newtonsoft)

I am trying parsing this JSON: {“”name””:””John Doe””,””age””:””34″”}”; All is ok. All is parsing. But if I change JSON on this (for example): #{“”name””:””John Doe””,””age””:””34″”}” It is invalid JSON. But may be Newtosoft can parse invalid JSON without errors (Ignore any errors and continue parsing? string test = @”#{“”name””:””John Doe””,””age””:””34″”}”; var settings = new JsonSerializerSettings…

Spring Boot – Returning JSON with array of objects

Using this answer as a hint, I developed a Spring Boot controller for /greetings to return greeting in different languages in JSON. While I am getting the output in the format (array of objects) I wanted, can you please let me know if there is a better way? package com.example.demo; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import…