json.net Questions

4

Solved

I have an object that I am serializing into Json using NewtonSoft Json.Net. The object is relatively large, the resulting Json is about 300kb, but the serialization process takes around 60 seconds....
Weeping asked 20/4, 2014 at 14:26

2

Solved

I want to deserialize JToken content to an object (User). How am I able to do this? Here is my json string: string json = @"[{""UserId"":0,""Username"":...
Tice asked 13/2, 2015 at 3:41

2

Solved

I'm using Newtonsoft to deserialize an known JSON object and retrieve some values from it if they're present. The crux is there is that object structure may keep changing so I'm using dynamic to tr...
Strother asked 8/4, 2022 at 17:41

3

Solved

I'm having trouble getting the new System.Text.Json to deserialize collections stored on read-only properties. Consider these classes: public class SomeItem { public string Label { get; set; } } ...
Triste asked 15/1, 2020 at 9:8

4

Solved

Is there a simple way to configure JSON.NET so that some DateTime fields will be formatted without time and other DateTime fields will still be formatted with time? Example: { firstName: 'John',...
Rhaetia asked 1/5, 2013 at 15:8

0

A while ago I switched from using .AddNewtonsoftJson() in my .NET Core 7 app to using .AddJsonOptions(). I came across an issue with nswag (circular reference) and needed to change the settings use...
Comanchean asked 22/9, 2023 at 23:4

5

Solved

I need to write the following data into a text file using JSON format in C#. The brackets are important for it to be valid JSON format. [ { "Id": 1, "SSN": 123, "Message": "whatever" }, { ...
Pelecypod asked 4/6, 2013 at 15:23

5

Solved

I always had the impression that the JSON serializer actually traverses your entire object's tree, and executes the custom JsonConverter's WriteJson function on each interface-typed object that it ...
Villarreal asked 25/3, 2015 at 21:38

4

Solved

I am trying to parse a json response that I get when calling a rest API. The problem I am facing is that the deserializing doesn't work every time, even though I am making the same request. I don't...
Fatsoluble asked 11/9, 2016 at 12:28

7

Solved

How can I get Json.net not to throw up when my enum doesn't match string value provided in the json property? This happens when I create enum based on current documentation, but the third party AP...
Zerlina asked 31/3, 2014 at 1:3

6

Solved

I've looked this question up, but I don't see too many answers, and obviously none have been helpful or I wouldn't be asking. I am a .NET neophyte. My local environment is Win7, Microsoft Virtual W...
Cuneiform asked 28/7, 2012 at 1:26

9

Solved

I have a dynamic object that looks like this, { "2" : "foo", "5" : "bar", "8" : "foobar" } How can I convert this to a dictionary?
Malodorous asked 27/2, 2014 at 9:31

3

I have some C# code using ASP.Net MVC, which is making use of Json.Net to serialize some DTOs. In order to reduce payload, I have made use of the [JsonProperty(PropertyName = "shortName")] attribut...
Schuh asked 16/12, 2013 at 22:44

2

Solved

I am trying to serialize an IPEndpoint object with Json.Net and I get the following error: Error getting value from ScopeId on System.Net.IPAddress. The cause of the error is that I am only using...
Pedagogy asked 7/9, 2013 at 0:55

6

Solved

Using the SelectToken method of JSON.NET to select a token with JSONPath, I found no way to specifiy that the search should be case-insensitive. E.g. json.SelectToken("$.maxAppVersion") should ...
Gymnastic asked 29/2, 2016 at 16:20

5

Solved

I'm having two controller controllers: ControllerA and ControllerB. The base class of each controller is Controller. The ControllerA needs to return JSON in the default format (camelCase). The Con...
Bidget asked 2/10, 2018 at 9:51

5

Solved

This is my first time ever using JSON as well as System.Net and the WebRequest in any of my applications. My application is supposed to send a JSON payload, similar to the one below to an authentic...
Sanguinaria asked 10/5, 2014 at 20:23

3

Solved

I am programming a game of questions and answers by categories in Unity. The categories are obtained through a PHP script that returns a JSON text,* when I use this solution in the UnityEditor it w...
Circle asked 5/12, 2019 at 11:29

7

Solved

I have heard that Json.NET is faster than DataContractJsonSerializer, and wanted to give it a try... But I couldn't find any methods on JsonConvert that take a stream rather than a string. For ...
Merrilee asked 16/11, 2011 at 19:41

4

Solved

I'm writing a JsonConverter to perform some conversion tasks I need accomplished on read/write. In particular, I'm taking the existing serialization behavior and tacking on some additional properti...
Recovery asked 18/4, 2013 at 14:33

10

Solved

When using JSON.Net in ASP.Net Core 2.2 I was able to ignore a property when its value was null when serializing to JSON: [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public DateTi...
Escritoire asked 25/9, 2019 at 21:8

4

newbie question: how do i make my JSON output ignore null values? I don't want to necessarily set each individual property to ignore null (as in decorate each property with [JsonProperty(NullValueH...
Silassilastic asked 31/3, 2022 at 21:40

13

Solved

I am creating a reusable library using .NET Core (targeting .NETStandard 1.4) and I am using Entity Framework Core (and new to both). I have an entity class that looks like: public class Campaign ...
Heida asked 29/6, 2017 at 15:49

6

Solved

Is there simple way using JSON in .NET to ensure that the keys are sent as lower case? At the moment I'm using the newtonsoft's Json.NET library and simply using string loginRequest = JsonConvert...
Volute asked 9/6, 2011 at 5:58

6

Solved

json.net (newtonsoft) I am looking through the documentation but I can't find anything on this or the best way to do it. public class Base { public string Name; } public class Derived : Base { p...
Seif asked 14/12, 2011 at 23:7

© 2022 - 2024 — McMap. All rights reserved.