342 questions
-3
votes
1
answer
67
views
Deserialize Json string on POST when result is returned in [X].Name format
Everything works as expected until the json string is deserialized after the post back.
Class:
public class RegretLetterDetail
{
public int PositionID { get; set; }
[Display(Name = "...
0
votes
0
answers
55
views
Custom primitive type collection in EF Core (8)
I have a nested entity, defined like this:
entity.OwnsOne(e => e.EncryptedElements, o =>
{
o.ToJson();
o.OwnsMany(x => x.Values, o =>
{
o.Property(x ...
1
vote
1
answer
118
views
Serializing and deserializing inherited class
So i have WeaponStats class that contains one of classes that inherit from IDamageType.
Fire is empty bacause i didn't receive anything back from game designer and its still empty. But i can add ...
-1
votes
1
answer
100
views
Best way to access nested attributes in JSON with Freezed in Flutter
I'm using Freezed and json_serializable in a Flutter project. My API returns a nested JSON like this:
{
"success": true,
"message": "Login successful",
"data&...
0
votes
1
answer
112
views
How does quarkus jackson reflection free optimization work?
Classes having JsonView annotated attributes provide different generated serializers with jackson reflect free optimization in quarkus.
I have the following attribute enabled in our project.
quarkus....
0
votes
0
answers
58
views
caching a serialized immutable object in Jackson
Use case
Say I have an HTTP endpoint that constructs an immutable object then sends that immutable object to multiple sinks. Maybe I send it to a couple of message brokers, other HTTP endpoints, a ...
0
votes
0
answers
39
views
JsonInclude.Include.NON_EMPTY Doesn't Work after I implemented custom serializer on an attribute
I have a class which has Include.NON_EMPTY configuration on class level.
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
public class Item extends ExtraInfo {
String id;
List<String> ...
0
votes
1
answer
602
views
System.Text.Json throws TypeInitializationException in .NET framework unit tests
I have created a (fresh) solution in Visual Studio 2022 17.12.4 with the following projects:
ClassLibrary1 (.NET framework 4.8)
Has System.Text.Json installed version 9.0.1
Has a static method Just....
0
votes
0
answers
87
views
Configure source-generated JSON serialization for all types in assembly
I'm building an ASP.NET Core Web API for AOT publishing and need to configure source-generated JSON serialization for it, as reflection-based serialization will not work for AOT.
According to ...
0
votes
2
answers
81
views
How to serialize the recursive dictionary in C#?
Below class is the recursive dictionary (tree-like structure). The EntityID is just the alias of string which must be accessed via HierarchicalRelationshipsMap.EntityID.
public class ...
0
votes
0
answers
282
views
How can I add custom converters to Npgsql EF Core (8) traditional POCO mapping?
I need to use traditional POCO mapping to jsonb with PostgreSQL and EF Core (.net 8). The structure of those classes in fairly complex and I don't need to query them with Linq to EF. But I need to be ...
0
votes
1
answer
87
views
Not creating the .g.dart class in Flutter(Dart)
I have used the json_serializable library in flutter and created a class and created the Annotation of the library i.e. json_serializable in the class as below example:
import 'package:json_annotation/...
0
votes
1
answer
302
views
How to use Newtonsoft JSON serializer for all Flurl 4.0 calls globally or per specific client
I need to use Newtonsoft JSON serializer for all calls made via Flurl 4.0 (or at least for all calls made by a specific Flurl client), but I cannot figure out how to set it up. From the answer to the ...
0
votes
1
answer
58
views
Parent abstract class field missing in json-serialization toJson() method in flutter
In flutter, I'm trying to define a form field model. The form type is a enum, based on which different Field are to be returned.
My text field should look like this on toJson():
type : "text"...
0
votes
1
answer
42
views
Jackson custom filter not triggered
I have a JSON object as:
{"username":"johndoe","email":"[email protected]",
"secretToken":"token123","secretKey":"password&...
0
votes
1
answer
329
views
Flutter and Freezed: Parse a json element from either string or int, "Null check operator used on a null value" on build runner
I'm working with Flutter and using Freezed for my data types and json deserialization. The database I'm working with will sometimes send the ID element as an int (without quotations) or as a string (...
0
votes
0
answers
59
views
JSON serialization with a group by query ... how to?
I have an API endpoint to pull a big JSON blob from one of my models, and it works, but I'd like to improve it. The current implementation is below, and mostly just works using built in associations.
...
1
vote
0
answers
169
views
do not serialize empty collections (and handle accordingly in deserialization)
I have a bunch of POCOs that can be (de-)serialized from/to json. A lot of content is collections. I want the serialized JSON to only contain a specific property if its collection is not empty (...
0
votes
0
answers
94
views
Write Access Violation when Serializing rapidjson::GenericDocument with PrettyWriter to GenericStringBuffer
I am working with RapidJSON and trying to serialize a rapidjson::GenericDocument object using rapidjson::PrettyWriter to a rapidjson::GenericStringBuffer. Here is the relevant part of my code:
typedef ...
0
votes
0
answers
24
views
From String to JSON back to String properties order
I cannot find how JSON order object properties.
I thought it was alphabetical, but it seems it isn't.
I've tried to find how JSON ordering object properties but I can't find it.
0
votes
0
answers
102
views
ASP.NET Core use dependency injection for custom type in xml output formatter
In my ASP.NET Core project, I have a custom type which needs to be serialized using some external service:
public struct MyCustomType
{
private int value;
public MyCustomType(int value) { ...
0
votes
2
answers
80
views
How to correctly manage databinding and serialization/deserialization of a BitmapImage?
That's my basic code:
public class MyObject
{
public decimal MyDeciaml { get; set; }
public string? MyImageBase64
{
get
{
if (MyImageBase64 != null)
...
0
votes
1
answer
79
views
Use WCF of .NET Framework to serialize a class as a primitive
I am using Windows Communication Foundation classes to serialize and deserialize classes to and from JSON in files via the DataContractJsonSerializer class. I know there are better ways to serialize ...
0
votes
2
answers
612
views
UE5 UPROPERTY variable name being serialized with camel case by FJsonObjectConverter::UStructToJsonObject
I'm using UE 5.3.
I have a UPROPERTY variable named 'issuetype'. When serializing using FJsonObjectConverter::UStructToJsonObject it produces 'issueType'. It only does this in packaged builds, not ...
2
votes
1
answer
343
views
Serialize Object using JsonConvert with specific format
I am using JsonConvert.SerializeObject method to serialize this object:
var objx = new JsonObject
{
["prob1"] = new JsonObject
{
["phone"] = "1019577756",
...
0
votes
1
answer
661
views
VS2022 17.9.3 C# interactive window, cannot use System.Text.Json
I get the following errors if I run Json import code in C# Interactive
From VS2022, View->Other Windows->C# interactive
Anyone knows how to import the libraries in C# interactive to get this to ...
1
vote
1
answer
579
views
How can I tell which JSON serialization will be used on my Azure function?
In Visual Studio, if I create a new project using the "Azure Functions" template, the JSON serialization used by that function will be different depending on which version of the template I ...
0
votes
0
answers
189
views
How to ignore null properties in HttpApplication json response in .Net Framework
Same question as
How to Ignore Null values while serializing OData response
and
.NET Core: Remove null fields from API JSON response
Only difference is how to do it in .NetFramework 4.7.2 with ...
0
votes
2
answers
372
views
How to test Azure function ObjectResult's JSON serialization
I'm working on a CustomClaimsProvider, although for the purposes of this question, all that matters is that it's an Azure Function with an HTTP trigger. The code here is based on the example code in ...
0
votes
1
answer
895
views
Custom JSON converter for the OpenSearchClient
Background: I have in the OpenSearch inconsistent data. Sometimes a given property is a string and sometimes it's a list of strings. I don't have a control over that.
When using System.Text.Json ...
0
votes
2
answers
545
views
Change property names conditionally during serialization
I have model classes ClassA and ClassB.
These classes are returned as result from two controllers: XController and YController.
When returning these classes as result from YController, default ...
0
votes
1
answer
337
views
How to generate a JsonSerializable with extended class
I'm creating a product app in clean architucture, I want to generate json but I cant to do it with JsonSerializable but I cant do it I always get error
Could not generate `fromJson` code for `...
1
vote
1
answer
302
views
How to enable serializing for REST applications in ASP.NET Core 8?
In my project, the server returns the empty object while I have checked that this.taskGateway.RetrieveSelection returns the correct data:
[ApiController]
public class TaskController : ControllerBase
{
...
0
votes
1
answer
163
views
JSON serialization of HTML entities
While working on deserialization of a JSON string that contains HTML data, I noticed the following:
< and > are converted to \u003c and \u003e
(Direct unicode representation)
& is converted ...
-2
votes
3
answers
604
views
C# Json object serialization with dynamic custom object
I have a C# class like the following:
public class FunctionCall
{
public string x {get; set;}
public int y {get; set;};
public object obj1 {get; set;};
public object obj2 {get; set;};...
1
vote
0
answers
505
views
Can pydantic do polymorphic JSON serialization based on a field like _type?
JDK Jackson has JsonSubTypes which can be based on a field like _type or @type or type etc. In our case we are using _operation. This field is absent from the fields of the deserialized object as it ...
3
votes
2
answers
5k
views
Number decimal precision with System.Text.Json
How do I write (serialize) a float to JSON with fixed 2 decimals using System.Text.Json?
Like {"Amount": 12.30}.
Not like {"Amount": 12.3} or {"Amount": 12.3001} or {&...
-3
votes
1
answer
69
views
gson.toJson returns empty object [closed]
I need to serialize java objects for one of my uni projects, but I don't have much experience in java. I was wondering why toJson keeps returning an empty object when I try to print it and why it ...
0
votes
1
answer
77
views
Could not write JSON: Infinite recursion (StackOverflowError)]
I am not getting "parent" field in response. If I remove @JsonBackReference annotation, the recursion will begin. I need to get parent object 1 time without recursion.
@Getter
@Setter
@...
1
vote
1
answer
546
views
How to fromJSON/toJSON of Geopoints or custom datatypes in Flutter using Freezed and Firebase (Have always build errors)
this is my first post here and for a student project, so I am very sorry if my format of questioning is incorrect. I created a minimal repo and run the build to recreate my error. The Goel is to ...
1
vote
1
answer
481
views
Flutter JSON serialization and Setters
In flutter I have a simple JSON serializable class for a location with just an ID and a name like this:
import 'package:json_annotation/json_annotation.dart';
part 'locations_data.g.dart';
@...
3
votes
2
answers
1k
views
ASP.NET Core 7 Web API - how to serialize in Pascal case?
In Visual Studio 2022, and .NET 7, I created a new project with the template ASP.NET Core Web API. The template creates the WeatherForeCastController, which uses the WeatherForecast model. The ...
0
votes
1
answer
446
views
Nestjs serialization in validation pipe not working
I am trying to use @Expose with an alias name for properties of a class as below but I am getting the response in camelCase.
import { Expose } from 'class-transformer';
import { BaseResponse } from './...
-1
votes
1
answer
64
views
Jackson Databind Deserializtion of Generic Enum
I am trying to properly save/load data containing a generic enum. Currently the object contains a java.lang.Class object (clazz) that get serialized into the field "enumclass". The "al&...
0
votes
0
answers
449
views
TypeError: Object of type ViTConfig is not JSON serializable when pushing a custom ViT model to Hugging Face Hub
I'm new to hugging face and hugsvision. I'm trying to push a custom Vision Transformer (ViT) model to the Hugging Face Hub. I've defined a custom configuration using ViTConfig, but I get this error ...
2
votes
3
answers
986
views
How to make all variables not required in json serializable
In json_serialization when i use the annotation @JsonKey(required: false), i am able to make a variable nullable, but then i have to annote all variables with this, it there a way to make this this ...
0
votes
1
answer
39
views
Construct dictionary with array value instead of serialized JSON string
I have some data from the bind grid view and I want to display them in a serialized format. Right now I have a nested array where the above parent is serialized correctly but the child array has ...
0
votes
1
answer
395
views
Check if json is deserializable to a specific type using Json.NET
I have a data model where several data classes are defined. This data classes are serialized in a Unity project (namely A) and then sent via TCP to another Unity project (B) which acts as a debugging ...
0
votes
0
answers
39
views
Internal toJson()-Method is not generated
I am having the following UserDto class:
part 'user_dto.freezed.dart';
part 'user_dto.g.dart';
@freezed
abstract class UserDto implements _$UserDto {
const factory UserDto({
required String ...
1
vote
1
answer
734
views
How to Represent a Union Type in Dart Similar to TypeScript for Creating a Data Class with json_serializable?
I am currently working on a Flutter project where I am trying to create a data class for a User that involves an Image property. In TypeScript, I have a union type Image that can be either a boolean ...