14,090 questions
0
votes
1
answer
26
views
Coding a Nested JSON object using Newtonsoft.Json
I am attempting to code a nested JSON object for an upload API endpoint. I am having issues forming the code for the nested object. When I call the endpoint to post the data to their site, I get a ...
0
votes
0
answers
54
views
Resolving conflicts between attributes and relationships in JsonApiSerializer
I'm working on a C# program that will integrate with Planning Center's json-api compliant API (docs can be found here.) For (de)serialization purposes, I'm using the JsonApiSerializer library, which ...
2
votes
1
answer
148
views
Deserialize complex JSON with data in keys
I am building an editor script for Unity to import a complicated blueprint JSON asset extracted from another game engine. Some of this data is stored in the keys, meaning I cannot follow a typical ...
3
votes
0
answers
90
views
JSchemaValidatingReader - OOM when handling large tokens
We have encountered some memory issues when validating JSON.
We are using:
Newtensoft.Json v 13.0.3
Newtonsoft.Json.Schema 4.0.1
.NET 9.0.304
For validation we have this code:
var validationResult = ...
0
votes
1
answer
150
views
Why is `JArray.ToObject<List<T>>` faster than `JArray.ToObject<T[]>`
We are trying to micro-optimise some parts of our production code and I was expecting that using Arrays would generally be better than Lists in .NET, and most of the times, my benchmarks indicate that....
3
votes
1
answer
100
views
How Can I Ignore One Property based on JsonProperty Value of another Property during Deserialization?
I have the following class, how can I ignore the Response, if StatusCode == 400?
If StatusCode is 400, Response is returned in a different format that doesn't match my APIResponse class and throws an ...
0
votes
1
answer
38
views
Getting exception during deserialization in PostgreSqlConnection.GetStateData method
I have a .NET 8 service which uses Hangfire library for async jobs. I have configured Hangfire with PostgreSQL database.
I need to check the state of a running job frequently for which I am using the ...
-2
votes
1
answer
95
views
Change values in JSON file
I have a JSON file with nested values, I want to change any value in the file (ex: "supplierIdentifier" value is "002264HAM001" want to replace it to "0194711AMM00".
...
1
vote
1
answer
183
views
Problem with serializing object structure with Newtonsoft Json.NET
I have to serialize a data structure for a 3rd-party interface either to XML or to JSON. The expected result should look like the following (simplified) example:
XML:
<?xml version=\"1.0\"...
0
votes
0
answers
36
views
Prevent Newtonsoft deserialising a field, but still allow it to serialise [duplicate]
For the following code (.net fiddle here) I'm coming across a deserialisation issue.
public static void Main()
{
var beef = new Beef()
{
Porks = [
...
-1
votes
1
answer
81
views
Unexpected end of string while parsing json [duplicate]
I have the following json string:
{
"tables":
[
"%USER%.ABCDE_FAC_FINAL_%YEAR%",
"%USER%.ABCDE_FAC_STAGE_%YEAR%",
"%USER%....
0
votes
1
answer
98
views
Newtonsoft JSON schema generates invalid schema with prefixItems instead of items in version 2020-12
I'm updating a C# addin for Sparx EA to generate JSON schema's from a model.
One of the changes is to allow the option to choose for the version 2020-12: "$schema": "https://json-schema....
0
votes
0
answers
60
views
Why does the Json.NET deserializer accept string values for boolean properties?
I expected this code to throw an Exception because I am trying to deserialize a string value into a boolean property. However, I was surprised to find that Json.NET happily converts the string value ...
1
vote
1
answer
46
views
Given an object graph composed of sub-classed of types which, how can we serialize that object to JSON while ignoring certain members of some types?
Given a C# object graph composed of subclasses of types which we cannot modify directly, what is the best strategy to serialize that object to JSON in .NET 4.6.2 while ignoring certain members of some ...
0
votes
1
answer
525
views
How to control trimming in dotnet publish with WebAssembly?
I'm currently working on a small client-side webapp using Avalonia and WebAssembly, specifically https://github.com/TheRealQuantam/ZeldaMusicRandomizer (Visual Studio 2022, in C#, with .NET 8.0 and ...
1
vote
1
answer
78
views
Custom StringEnumConverter is not picking up all Enums [closed]
I have a package of records for serialising and deserialising published in a private GitHub Repo for my project. Within one of them are a number of Enums. I am working with a GraphQL backend, and in ...
1
vote
1
answer
122
views
Populating enums without exception
In our C# application on .NET 4.8, we tried to use a PopulateObject for deserializing data returned from an API. This API is not under our control.
Now the API developer added a new enum value and ...
0
votes
0
answers
71
views
Object posted to api is Null in .NET 8 client but works in Framework 4.8
I have a client winform application originally targeting .NET framework 4.8 that I have upgraded to .NET 8. The client sends the class to a local server MVC.3 api that saves the entity to the server. ...
1
vote
0
answers
35
views
Parse Json Date String With Milliseconds [duplicate]
I'm trying to parse this Json file with Newtonsoft parser (v13.0.0.0):
{
"version": {
"elements": [
{
"key": "DateGenerated&...
0
votes
2
answers
84
views
Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type System.Windows.Ink.Stroke
I'm trying to save strokes and children from a WPF InkCanvas. I managed to get the file to save, but now I can't load it. It throws this exception:
Newtonsoft.Json.JsonSerializationException
HResult=...
1
vote
1
answer
122
views
Graphql Newtonsoft serializer throws error while parsing enum
I have a .NET Core GraphQL backend service consumed in a Blazor web assembly app with a GetData GraphQL query with an enum like this:
public enum SomeEnumTypes : byte
{
None,
First,
...
-1
votes
1
answer
108
views
Object-based JSON array decoding in C# [duplicate]
Having to decode an unusually-formatted JSON array, where instead of being an array, the contents are complete objects:
{
"133v1": {
"128": "2024-01-24",
...
0
votes
1
answer
53
views
Newtonsoft Json.NET DefaultValueHandling and DataSets
I am trying to serialise a DataSet (working with an old codebase and have to use a DataSet in this instance). I want to slim down the resulting JSON and remove null values and defaults (0 for int, ...
-1
votes
2
answers
69
views
Deserialising json with JSON.NET , unable to find the right class format [duplicate]
I receive a Json file. Now the other company change the Json and I have to find the right format for my class in C.Net and I'm not able to do so.
My Json looks like :
{
{"xxx": [
"...
0
votes
1
answer
83
views
Getting default values using TypeNameHandling in Newtonsoft JSON
I'm doing a basic serialize / deserialize with $type included to implement the outbox pattern. however I'm getting the default values.
Here's the code serializing :
JsonConvert.SerializeObject(...