json.net Questions

1

Json.NET version 10 added support to async serialization. Version 11 added support to generic JsonConverter<T>. The problem is that JsonConverter<T> and previous JsonConverter only sup...
Chequer asked 2/4, 2018 at 11:21

4

I get the following error with the code below: "An object reference is required for the non-static field, method, or property 'Response.PropName'" Code: public class Response<T> : Res...
Hypoblast asked 24/8, 2016 at 16:31

3

Solved

In my current project I have the problem that I end up in an infinite loop when trying to convert an Item or any of its subclasses like ArmorItem. To detect which type of Item I have to deserialize...
Scroop asked 25/9, 2015 at 13:56

4

Solved

I have a Web API application that returns JSON to consumers who may not be using Microsoft technologies. When my controller returns an object with DateTime properties as JSON, it serializes the dat...
Gymnosophist asked 15/3, 2017 at 13:36

6

Solved

I am using Newtonsoft's JsonSerializer to serialise some classes. As I wanted to omit one field of my class in the serialisation process, I declared it as follow: [JsonIgnore] public int ParentId...
Alcaeus asked 23/2, 2015 at 12:46

2

Solved

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...
Acropolis asked 28/6 at 12:40

6

I am passing a JSON payload to an API Controller, and one of the fields is dynamic because the field needs to be passed again as a JSON string to another API. The dotnet core 3.1 middle layer shoul...
Within asked 29/2, 2020 at 12:14

4

First I made an application and then I've started doing test for it ( Know it is not good way ), everything works fine with parsing etc, but after i made few test got an error : Newtonsoft.Json....
Thaumaturgy asked 24/11, 2016 at 15:38

3

Solved

I'm migrating an old API to .net core web api and one of the responses includes the same value twice, so I'm using the native Json library of .NET 5 and I'm trying to get the same value twice in th...
Trifling asked 5/10, 2021 at 10:6

3

Context: I need to pass an object containing a large number of properties/fields (to UI Layer from Middle Tier Layer). Among this list of properties, one is of type Version which is not getting des...
Caressive asked 1/11, 2012 at 3:6

5

Solved

I have used the "JsonConvert.Deserialize(json)" method of Json.NET so far which worked quite well and to be honest, I didn't need anything more than this. I am working on a background (console) ap...
Perseverance asked 26/8, 2015 at 13:3

6

Solved

I have a class with an internal list. I don't want the user of this class to be able to interact with the list directly, since I want to both keep it sorted and to run a calculation (which depends ...
Pegeen asked 9/12, 2014 at 19:20

5

Solved

I'm working on a protocol in which the receiver will receive json messages of certain specified custom types (currently 5, but could be 10-20). I'm struggling to come up with an optimal/fast soluti...
Peppel asked 31/7, 2016 at 1:29

2

Solved

I am quite new to c#, xUnit as well as Newtonsoft.Json. While I am trying compare two different JOject using Assert.Equal() method in unit test, it pass, refer to the below example code using Newto...
Abiogenesis asked 12/5, 2023 at 9:3

10

Solved

With a simple class/interface like this public interface IThing { string Name { get; set; } } public class Thing : IThing { public int Id { get; set; } public string Name { get; set; } } Ho...
Tubate asked 15/6, 2013 at 12:49

6

Solved

I am trying to deserialize a json string received as a response from the service. The client is Windows Phone 7, in C#. I am using Json .NET - James Newton-King deserializor to directly convert the...
Epigraphy asked 13/11, 2011 at 3:50

5

I just got a hold of JSON.NET and its been great so far. However, I cannot figure out how to determine the type of a serialized object when deserializing it. How can I determine the object's clas...
Spracklen asked 20/1, 2014 at 23:58

8

Solved

Using .Net Core 3's new System.Text.Json JsonSerializer, how do you automatically cast types (e.g. int to string and string to int)? For example, this throws an exception because id in JSON is nume...
Backfire asked 29/11, 2019 at 1:31

14

Solved

We have some configuration files which were generated by serializing C# objects with Json.net. We'd like to migrate one property of the serialised class away from being a simple enum property into...
Archibold asked 19/7, 2012 at 15:25

3

Solved

I have class like this: public class Pussy { public readonly int Meows; [JsonConstructor] private Pussy() { } public Pussy(int meows) { this.Meows = meows; } } When I'm trying to serial...
Amortization asked 1/10, 2015 at 13:16

3

Solved

I want to migrate my code from Newtonsoft Json.Net to Microsoft standard System.Text.Json. But I could not find an alternative for JToken.DeepEqual Basically the code must compare two JSON in unit ...
Remnant asked 7/3, 2020 at 18:11

5

Solved

I'm trying to reduce the amount of garbage my web service generates, and I noticed that we're creating a new Json.NET JsonSerializer instance for each request. It is not the most lightweight object...
Chinfest asked 23/3, 2016 at 18:42

4

Solved

I want to deserialize a 2-dimensional array to a collection of .net objects. The reason is, array syntax will be easier for my user to work with in an input file. So I just want to map the indices ...
Bowerbird asked 21/4, 2016 at 0:14

5

Solved

I am using JSON.Net as my serializer for a large MVC 3 web application in c# and the Razor view engine. For the initial page load in one view, there is a large amount of JSON dumped inside a script...
Dorton asked 20/8, 2012 at 17:35

4

Solved

I need to get the first child of JObject. This is how I temporarily solved it with foreach loop breaking after first iteration. foreach (KeyValuePair<string, JToken> item in (JObject)json["s...
Aeolus asked 16/1, 2015 at 19:15

© 2022 - 2024 — McMap. All rights reserved.