Category "json.net"

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

Could not load Newtonsoft.Json. Issue with .net framework / core / standard versions

[EDIT 3: bottom line, this stuff can work but is fragile. take a false step and VS will pull in undesired versions. Be prepared to backup, undo changes, and tr

Unexpected character encountered while parsing value

Currently, I have some issues. I'm using C# with Json.NET. The issue is that I always get: {"Unexpected character encountered while parsing value: e. Path '',

Not allowed to load local resource:

i want to stream online videos ..but i am facing j query error Not allowed to load local resource: ...i find many solution but that all did not work for me. he

Json.NET in Unity throwing 'The type or namespace `Newtonsoft` could not be found'

I used nuget to install Json.NET into my Unity project but the issue is when I launch it throws The type or namespace 'Newtonsoft' could not be found. Are you m

Json.NET in Unity throwing 'The type or namespace `Newtonsoft` could not be found'

I used nuget to install Json.NET into my Unity project but the issue is when I launch it throws The type or namespace 'Newtonsoft' could not be found. Are you m

Can I Deserialize a specific field from JSON?

I am writing a method that takes a British post code and returns the Latitude and Longitude of this postcode as a "Location" object. public class Location {

Json.NET: how to remove assembly info from types in the resulting json string?

I am serializing using Json.NET, but the resulting string ends up way too long, because it includes a ton of surplus info about the assembly that I have no use