Questions tagged [json.net]
Json.NET (also known as Newtonsoft.Json) is a popular high-performance JSON framework for .NET.
json.net
13,817
questions
0
votes
0
answers
10
views
Serialize class components as direct part of class?
I was wondering if there was a way to serialize and deserialize a class so that a component is treated as part of that class.
public partial class LevelObjectConfig : ObservableObject
{
[...
0
votes
0
answers
31
views
dotnet build "Could not resolve this reference. Could not locate the assembly" error but only occurs on CI?
I have a simple CI that builds my solution on GitLab. The project consist of a .NET Core project and a WCF project. I am encountering an error after installing the latest version of Newtonsoft JSON ...
0
votes
1
answer
31
views
Read json dictionary with multiple sub keys into unity c# script
I am trying to get my data from a json file into unity with a c# script. The goal is to move all players at the same time based on positional data, which i already have. I need to group the ...
0
votes
1
answer
22
views
JToken.FromObject adds square brackets for child
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
Dim dtTICKET As New DataTable
dtTICKET.Columns.Add("Title", GetType(String))
dtTICKET.Columns....
0
votes
0
answers
53
views
Serializer not returning expected output in .NET Core
I have a controller which returns Task<ActionResult> which internally returns a List<CustomObjectA>.
The structure of CustomObjectA is like this:
[DataContract]
public class CustomObjectA
{...
0
votes
2
answers
43
views
How to extract string content of JObject as is?
Look at this code
Dim jsonString As String = "{
""uuid"": ""4b84ca0c-40c8-4c2e-b1af-ddd727f3d0cf"",
""side"": ""bid&...
0
votes
1
answer
42
views
cannot convert from 'string' to 'Newtonsoft.Json.JsonReader'CS1503 error showing up how to i convert to newtonsoft.Json.JsonReader?
I was trying to retrive information from a json file and save it to mapCollision and layers
but CS1503 error showing up
the json file includes 2 jagged arrays which represent a map
{
"layer&...
0
votes
1
answer
52
views
How to configure Newtonsoft JSON.NET serializer settings for Swagger example classes?
I am using Newtonsoft JSON.NET for object serialization in an ASP.NET Core (.NET 8) project implementing REST APIs and I need to change serialization settings used for Swagger examples from ...
0
votes
0
answers
29
views
System.Text.Json ecapes single quotes by design [duplicate]
I know that System.Text.Json escapes single quotes by design, but the examples for how to allow certain characters to not be escaped from MS Docs doesn't work for me as I want to keep single quotes in ...
1
vote
1
answer
75
views
C# Newtonsoft JSON Deserialization: Empty list value represented as "{}" instead of "[]", throws exception
We are currently supporting an API integration with a 3rd party that transmits responses via JSON. We are using C# .NET and Newtonsoft JSON (version 13.0.1) to handle serialization of requests and ...
0
votes
1
answer
49
views
Dynamically set the Property name to be the name of the Type(typeof(T).Name)
var appsettings = JsonConvert.DeserializeObject<AppSettings<PersonModel>>(configData);
class AppSettings<T>
{
[JsonProperty(PropertyName = typeof(T).Name)]
public T ...
0
votes
0
answers
66
views
In C#, why does System.Text.Json.JsonSerializer.Serialize fail to serialize correctly when using dependency injection (interfaces)? [duplicate]
Why does the following write out only "{}"?
var myLogin = new TestLogin
{
UserName = "[email protected]",
Password = "Pass123"
};
Console.WriteLine(System.Text.Json....
0
votes
0
answers
40
views
Ban entire namespace with BannedApiAnalyzers
I am trying to ban the usage of Newtonsoft.Json package in my codebase, and I am trying to use the BannedApiAnalyzers Nuget package (latest stable version, 3.3.4).
My problem is that while I am able ...
4
votes
2
answers
115
views
How to compute byte size of list<T> in C#
I want to send a large list of objects to another web service for intake. The web service has a byte limit of 6Mb. I want to send my list of 7,000+ objects in 5Mb "batches."
To do this, I ...
0
votes
1
answer
75
views
Newtonsoft: How to find self-referencing loop?
I'm getting an error when I attempt to serialize an object:
Self referencing loop detected with type 'Namespace.MyClass'. Path ''.
I understand what this error means. Somewhere in my class, I have a ...