system.text.json Questions
4
Solved
I'm storing some IConfiguration as json in my sqlserver db so I can then bind them to some already constructed classes in order to provide dynamic settings.
At some point I might change the binded ...
Glowworm asked 3/7, 2020 at 10:29
4
Using System.Text.Json i can pretty print json using serialization option.
var options = new JsonSerializerOptions{ WriteIndented = true };
jsonString = JsonSerializer.Serialize(typeToSerialize, op...
Scribble asked 7/1, 2021 at 22:7
10
Solved
I have this json
{"id":"48e86841-f62c-42c9-ae20-b54ba8c35d6d"}
How do I get the 48e86841-f62c-42c9-ae20-b54ba8c35d6d out of it? All examples I can find show to do something like
var o = System....
Serpentiform asked 28/8, 2019 at 22:14
5
Solved
I am trying to deserialise the following JSON
{"serverTime":1613967667240}
into an object of the following class
public class ApiServerTime
{
[JsonPropertyName("serverTime")]
...
Acidulous asked 22/2, 2021 at 5:24
5
Solved
I'm using Ubuntu and dotnet 3.1, running vscode's c# extension.
I need to create a List from a JSON file, my controller will do some calculations with this model List that I will pass to it
So, her...
Trimetrogon asked 27/1, 2020 at 22:52
3
Solved
I'm trying to deserialize json into an object with a property of type Dictionary<string,string>. I specify the comprarer for the Dictionary as StringComparer.OrdinalIgnoreCase.
Here's this cl...
Scutiform asked 28/4, 2021 at 20:47
3
Solved
With Newtonsoft Json you can convert an object to a JObject by calling JObject.FromObject(object).
Is there a counterpart in System.Text.Json to get a JsonDocument from an object?
Sanborn asked 6/3, 2020 at 13:57
1
Solved
Using System.Text.Json, is it possible to serialise an array such that each array item appears on a new line but each line is minified? Here is my console app attempting to use Utf8JsonWriter to wr...
Overtake asked 20/5 at 15:15
3
Solved
Deserializing using JsonSerialize.DeserializeAsync and a custom converter, e.g.
public class MyStringJsonConverter : JsonConverter<string>
{
public override string Read(ref Utf8JsonReader re...
Dhu asked 23/5, 2021 at 11:10
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
6
I'm migrating a project from Newtonsoft.Json to System.Text.Json in .NET 5.
I have class:
abstract class Car
{
public string Name { get; set; } = "Default Car Name";
}
class Tesla : Car...
Garner asked 11/1, 2021 at 9:18
3
Solved
Web API in ASP.NET Core 7 with System.Text.Json:
I need to reject JSON payloads on PUT/POST APIs which have additional properties specified which do not map to any properties in the model.
So if my...
Blindstory asked 3/1, 2023 at 15:15
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
I've migrated a web api application from net core 5 to 6 and changed NewtonSoft serializer by System.Text.Json. In my Startup.cs, I've configured Json serialization with the following code:
service...
Schaefer asked 4/1, 2022 at 10:27
3
Solved
I am updating some apps for .NET Core 3.x, and as part of that I'm trying to move from Json.NET to the new System.Text.Json classes. With Json.NET, I could deserialize an anonymous type like so:
v...
Idioglossia asked 12/12, 2019 at 21:55
12
Solved
Instead of this:
JsonSerializerOptions options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
// etc.
};
var so = JsonSerializer.Deserialize<SomeObject>(som...
Garber asked 10/10, 2019 at 21:42
8
Solved
I have a master class which contains a generic collection. Elements in the collection are of diffetent types, and each implements an interface.
Master class:
public class MasterClass
{
public IC...
Furunculosis asked 14/10, 2019 at 9:32
3
Solved
What is the equivalent of Newtonsoft.Json's JsonProperty attribute in System.Text.Json?
Example:
using Newtonsoft.Json;
public class Example
{
[JsonProperty("test2")]
public string Tes...
Rabinowitz asked 20/10, 2019 at 17:46
2
Solved
I am working on a .Net 6.0 project, and I want to migrate from Newtonsoft.Json to System.Text.Json. So far most is working, except the following:
I've got this json:
[
{
"Key":"Val...
Cordierite asked 22/11, 2021 at 13:31
6
I am migrating a web API from .NET Core 2.2 to 3.0 and want to use the new System.Text.Json. When using Newtonsoft I was able to format DateTime using the code below. How can I accomplish the same?...
Epideictic asked 25/9, 2019 at 15:47
3
Solved
C# 10 / .NET 6 / System.Text.Json
I'm working with an API that returns as JSON response. I'm trying to use System.Text.Json to deserialize the JSON response into a class. I'm receiving a JsonExcept...
Flip asked 8/2, 2022 at 18:21
7
Solved
Lets say that I request a large json file that contains a list of many objects. I don't want them to be in memory all at once, but I would rather read and process them one by one. So I need to turn...
Favouritism asked 26/10, 2019 at 16:15
1
Seems .NET suffers the same problem with long.MinValue and long.MaxValue as Java
described in this post: Why java LONG_MAX is not same with vue axios data?? How to fix that?
Both samples use System...
Consubstantiate asked 2/1 at 13:26
3
Solved
I am using System.Text.Json package to use the serialization and deserialization.
I can deserialize a json string into an object when the type is explicitly specified like below.
var data = JsonSer...
Lector asked 31/3, 2022 at 15:30
4
Solved
I am passing in a valid JSON object to my controller on my .net core 3 web api application. Doing so, I get the error:
System.NotSupportedException: Deserialization of interface types is not sup...
Aubin asked 5/12, 2019 at 20:47
1 Next >
© 2022 - 2024 — McMap. All rights reserved.