Category "json.net"

c#/json.net deserialize child with data from parent

class Item { public string Id; public List<Item> Children; } json { "Id" : "/parent", "Children" : [ {

HTTP Post request method does not execute. How to use HttpClient?

I'm trying to make a post request using HttpClient. The expected json which I'm trying to post is stored in var result and looks like : { "ID": 142, "Statio

Complicated Json to C# Object Deserialize with classes

I am trying to deserialize a json response I get from a web call. I have it 90 percent figured out. The only part I am having a hard time figuring out is there

Complicated Json to C# Object Deserialize with classes

I am trying to deserialize a json response I get from a web call. I have it 90 percent figured out. The only part I am having a hard time figuring out is there

How to change a key value pair within a nested json structure C#

Hello everyone and thanks for helping me in advance. The following question might sound silly but I'm a beginner about it. I have the following json which comes

How to configure NewtonsoftJson with MinimalApi in .NET 6.0

I have net6.0 project with minimal api and I would like to use NetwtonsoftJson instead of built in System.Text.Json library for serialization and deserializatio

Is there a way to dynamically filter the JSON?

I am searching a way to filter the JObject according to the request from URL. Second code block works as expected and removes the "Id" column from response: My

Shorten JSON reading class

I have a simple JSON reading class that should grab values from a JSON object and put it in c# variables. Right now it uses 8 if statements, but I was wondering

Deserialize json with dynamic objects that starts with pattern

I'm trying to deserialize some json that looks like this { "id":"2021", "descriptions_bg":[ "30231300", "30233160", "32420000", "3

ASP.Net core - blank response when returning a JObject property

I am using ASP.Net core 5.0 and want to return IEnumerable of an object as Action method response. Here is the response class: public class TestResponse { p

.NET Newtonsoft Allow property to be only serialised

I have implemented the answer from this (rather old) question https://stackoverflow.com/a/31732029/4180176 but it doesn't seem to work for me and I can't figure

Serialize Enum as DisplayName or EnumMember Value

I have an enum declared in c#. I have a Display Name/ EnumMember value annotation and Student Class. I'm using asp.net core 2.2+ version with Odata. [DataContra

How to add a JProperty based on conditional statement within a Json.Net object

I want to add a JProperty field in a JObject based on the result of a conditional statement, but I'm having trouble formatting the code. string zip = "00000";

Serialize Newtonsoft JSON to byte array

What I am aiming to do is send JSON containing a header object and a compressed data in a field that is byte array. [JsonObject(MemberSerialization.OptOut)] pub

Could not determine JSON object type for type "Class"

I got the following error while trying to add an object of type class to the JArray. Could not determine JSON object type for type "Class" Here is my code: pr

How to deserialize interfaces with Newtonsoft Json.Net

I have this class hierarchy : public class ProxyBotsSnapshotLogEntryDetails : IBotsSnapshotLogEntryDetails { public ICollection<IBotSnapshot> Snapsho

Converting JObject to a dynamic object

I am calling a REST endpoint from C# and I am receiving json which gets serialized into an object. One of the properties on this object is a dynamic property. T

GitHub actions deploys wrong version of Newtonsoft.Json nuget package to Azure

I have a GitHub action doing .net solution build, test and deploy to Azure: name: Build and deploy ASP.Net Core app to Azure Web App - project-test-api on: p

MissingMemberHandling.Error force exception when deserializing the HTTP body

I am creating a restful web-service using .net and Newtonsoft for serialization/deserialization. The aim is to force exceptions (preferably HTTP 400) when a re

JSON.Net serializing Enums to strings in dictionaries by default - how to make it serialize to int?

Why does my serialized JSON end up as {"Gender":1,"Dictionary":{"Male":100,"Female":200}} i.e. why do the enums serialize to their value, but when they form th