Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
2 answers
40 views

Deserialize JSON objects do different class names

I am using System.Text.Json to deserialize objects from an external API call in C#. I have created the classes for the data and is very straight-forward. public class DocumentListRoot { ...
JimboJones's user avatar
0 votes
2 answers
35 views

Mock and verify request object passed to PostAsJsonAsync

Is there are way to verify the request object passed to HttpClient.PostAsJsonAsync. The request object is constructed inside the method to be unit tested. Therefore I need to verify that the request ...
arjun's user avatar
  • 11
0 votes
2 answers
53 views

Formatting parameters for C# HttpClient.PostAsJsonAsync

I don't have experience with REST APIs but I inherited one that I need to develop a C# .NET Framework 4.71-based client for. I figured out how to invoke commands that don't need parameters. For ...
Jim C's user avatar
  • 4,628
0 votes
0 answers
17 views

System.Net.Http.Json is not taking Fields into account when serializing or deserializing to JSON [duplicate]

When trying to Serialize a model which has data stored in fields System.Net.Http.Json is outputting an empty JSON Object. It works only when I use property with getters and setters. I tried looking ...
Jai dewani's user avatar
-2 votes
1 answer
48 views

C# JSON: I want to deserialize an empty string to a custom type. But it seems to be always defaulting to null. Is there a way to achieve this

I want JsonConvert.DeserializeObject<CustomType>("") to be deserialized to new CustomType() but this is always deserialized to null. this is using Newtonsoft json, have tried using a ...
Kaushik Ravi's user avatar
-4 votes
2 answers
45 views

How to create one time collectible coins in Unity?

I have created coins in a scene in unity that the player can collect and will disappear upon collection. however when the player leaves the scene and then comes back the coins reappear how can I ...
Thomas Wilson's user avatar
1 vote
1 answer
88 views

Json.Net How to Serialize and Deserialize custom types in custom way

I use the R3 reactive programming library and Newtonsoft. I'm trying to save object data to a file so that I can later read from it. The recording just works without problems. But when reading the ...
Maers's user avatar
  • 13
0 votes
2 answers
60 views

How to bind json data to FromBody Dto in ASP.NET Core Web API?

In my ASP.NET Core Web API, when I call a method that is a HttpPost and receives a DTO object in FromBody, and sends extra fields that are not in SourceUrlDto, I fail during binding on the code side. ...
Ahmet Kalem's user avatar
-1 votes
1 answer
47 views

How do I query System.Text.Json.Nodes.JsonArray by value in .net core c#

I wanna query an System.Text.Json.Nodes.JsonArray by prop value , Is there any JsonArray function can query JsonObject in which array index without foreach/forloop or extra libray ? [ {"...
民麒張's user avatar
0 votes
0 answers
28 views

How to read `DeclaringType` from `JsonPropertyTypeInfo` in System.Text.Json?

I want to customize serialization based on the type of the property. To do that I would like to read DeclaringType from JsonPropertyInfo. This is an example from Microsoft documentation on how to ...
Ilya Chernomordik's user avatar
1 vote
3 answers
94 views
+50

Passing two parameters (IFormFile and a string) with JSON to C#

Versions: ASP.NET and Web Tools - 17.10.341.11210 C# Tools - 4.10.0-3.24312.19+ JQuery - 3.3.1.js JS - 2.8.3.js I'm trying to pass an IFormFile and a string from a JSON file select and a string input. ...
Kevin Fischer's user avatar
0 votes
1 answer
33 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 ...
Vintertid's user avatar
1 vote
0 answers
37 views

Migrate public contract with property of JObject type from Newtonsoft to System.Text with backward-compatibility

I have a contract defined like this: using Newtonsoft.Json; using Newtonsoft.Json.Linq; public class Foo { [JsonProperty("type")] public int Type { get; set; } [JsonProperty(&...
Alexander's user avatar
  • 149
0 votes
2 answers
54 views

Problem with Serializing JSON to CamelCase in C#

I am trying to serialize a JSON string to convert property names to camelCase using the System.Text.Json library. However, I still get the outcome with PascalCase. Here is my code: var stringJson = &...
Krystian's user avatar
-1 votes
0 answers
25 views

Return view from nested classes in ASP.NET MVC for complex json String

My Model is : (Problematic section is Variant[] Variants, that is not passing to controller) public class SingleProduct { public Product1 product { get; set; } } public class Product1 { [...
Samie Ullah's user avatar

15 30 50 per page
1
2 3 4 5
1808