Questions tagged [json-serialization]
302 questions
0
votes
2 answers
How can I serialize a property in an inherited ICollection class?
I have a class that presented like
public class ItemCollection : ICollection {
public ItemCollection() {
Items = new List();
}
public List Items { get; set; }
...
}
Now it will be serialized into:
{
…

KAMyAw
- 21
- 3
0
votes
1 answer
Hangfire: JsonSerializationException: Self referencing loop detected for property 'Role' with type 'Shared.Models.Role'. Path 'Roles[1].Users[0]'
I'm trying to create a backgroud job in the Api controller of my Blazor wasm App.
It start a simulation as background job.
The simulation method is a extension method of the database context.
Exception happens on BackgroundJob.Enqueue() line.
API…

Ridvan Tahir
- 39
- 5
0
votes
2 answers
Using the cosmosdb SQLAPI, I'm able to create the partitionKey and ID I'm specifying, but no other content
I'm using the CosmosDB SQLAPI to create temporary storage of debug data during email processing. I only have less than a dozen known senders, and only a couple of hundred known recipients of that email. So, here's my code for Upserting into…

Chuck
- 55
- 5
0
votes
1 answer
Java RestAssured API POJO Class Cannot deserialize value of type `POJO.Category` from Array value (token `JsonToken.START_ARRAY`)
I have created couple of POJO classes for serializing/deserializing. When I create a request to receive all categories I am expecting to receive an array of category objects. But I am getting the following error:-
Exception in thread…

ED209
- 588
- 1
- 9
- 26
0
votes
1 answer
Exclude StackTrace when serializing Exception to Json using JsonConvert
I'm using the code below to serialize 'objects' to Json:
var settings = new JsonSerializerSettings
{
DefaultValueHandling = DefaultValueHandling.Ignore,
NullValueHandling = NullValueHandling.Ignore,
};
var ObjectJson…

R. Hoek
- 916
- 8
- 27
0
votes
1 answer
Golang. Map to JSON, but preserve the key order
I've a map object and when it's serialized using json.Marshal(myMapObjct) the Golang sorts the keys in alphabetic order, which is causing issues on how the data is being processed. It's important to preserve the key ordering once the JSON structure…

ZARKONES
- 61
- 1
- 7
0
votes
1 answer
How to serialize a class containing a collection of an abstract class?
Lets take a look at a simple class hierarchy consisting of three classes:
An abstract base class:
abstract class BaseClass {
String name;
BaseClass(this.name);
}
A few classes derived from the abstract base class.
@JsonSerializable()
class…

SePröbläm
- 5,142
- 6
- 31
- 45
0
votes
1 answer
check property values before deserializing JSON into C# Objects
I have the following json being returned by a third party api
{
'category':'Cat1',
'date': '12-12-2021'
'amount' 23.23
}
which is being deserialized to following C# class
public class Quote{
public string category {get;set;}
…

j4rey
- 2,582
- 20
- 34
0
votes
2 answers
Get Null values in response for certain use case
I am aware that in a Spring Boot project, I can filter out null valued attributes in response using @JsonInclude(JsonInclude.Include.NON_NULL). But what if I want to return null values for certain use cases which I am driving based on input from…

MittulRazdan
- 13
- 8
0
votes
0 answers
Customize the serialization behavior of ASP.NET ControllerBase
I am building a REST service that serves up data either from my database or a mock location.
[Route("[controller]")]
public class ProjectController : ControllerBase
I have an interface that defines the properties I actually need in the…

Denise Skidmore
- 2,286
- 22
- 51
0
votes
0 answers
Serialize gson with single quoted output
Gson will deserialize non-conforming single quoted JSON perfectly. Unfortunately I need to serialize a random interior object that was passed in with single quotes instead of double quotes. The output should look like the object below - see the key…

John Estess
- 576
- 10
- 22
0
votes
1 answer
Error serializing and deserializing json using polymorphism in java
I'm trying to manage different value structure using polimorphism. The next example contains 2 jsons that should be deserialized into the same parent object
{
"maximum": {
"type": "type1",
"value": {
"USD": 1000000,
…

Luismi
- 1
- 1
0
votes
1 answer
How to properly dynamically create custom JSON through Serializer
I have a roadblock where I have to transform a simple User class to a very specific JSON in the form of
{"fields": {
"Name": {
"stringValue": "test"
},
"Password": {
"stringValue":…

ConfusedStudent
- 111
- 9
0
votes
2 answers
Serialize jackson setting the default type for a pojo
I've a pojo as below:
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = @class)
public class Shape {
public final String abc;
public final String xyz;
}
Rest api accepts object of Shape as a parameter,…

tez
- 119
- 1
- 1
- 14
0
votes
1 answer
How to convert an object to a serializable JSON in swift
I'm the type to scour the web when I block but now I can't find or understand.
I have to do a simple post to an API, but I can't pass my object in parameters of my request.
When I test my var parameters with let checker =…

stod
- 3
- 1