Questions tagged [system.text.json]

System.Text.Json is the built-in JSON facilities added in .NET Core 3.0.

The System.Text.Json namespace provides high-performance, low-allocating, and standards-compliant capabilities to process JSON, which includes serializing objects to JSON text and deserializing JSON text to objects, with UTF-8 support built-in. It also provides types to read and write JSON text encoded as UTF-8, and to create an in-memory document object model (DOM) for random access of the JSON elements.

Additional details can be found in the how to article.

973 questions
0
votes
1 answer

System.Text.Json Deserialize object with multiple child objects into the same instance

Maybe somewhat of an odd use case, but I have a large amount of json that I need to put into a database, but the issue is that there are multiple occurrences of the author object within the json object that I need to refer to the same author…
BlueFrog
  • 1,147
  • 1
  • 7
  • 15
0
votes
0 answers

System.Text.Json how to deserialize

I have implemented a EANCode13 class with a constructor with a parameter like this: public class EAN13Code { public EAN13Code(string value) { // validate it } [JsonConstructor] public EAN13Code(long value) { // validate it …
Don Box
  • 3,166
  • 3
  • 26
  • 55
0
votes
1 answer

Unable to find dependency on pre-build aplication, Installer Visual studio C#

I have a project that references libreries with netstandar 2.0. When the project compile there are not problems, but when I try create an installer is just not working. Well, the file is created but the application does not work properly,…
Josue Cc
  • 28
  • 4
0
votes
1 answer

JsonSerializer dosen't deserialize any collection but deserializes all the rest of the object

Assuming I have an array of the following JSON data: [ { "foo": "somestring", "foo1": 2, "foo2": [ "somestring1", "somestring2" ], "foo3": [ { "bar1": 122312, "bar2": 3214324 }, { …
Aviv Vetaro
  • 363
  • 5
  • 12
0
votes
2 answers

avoid property name allocation in System.Text.Json

I'm writing a custom json serializer based on System.Text.Json, reading utf-8 string from array. In the examples I have found a following code: string propertyName = reader.GetString(); if (propertyName != "TypeDiscriminator") { throw new…
python_kaa
  • 1,034
  • 13
  • 27
0
votes
2 answers

Unable to round-trip JSON in ASP.NET Core - because I did something stupid

I'm trying to move a ASP.NET/MVC-.NET4.5 web application to ASP.NET CORE .NET 5.0, and I can't get json serialization/deserialization to work. This depends upon the server being able to send json objects to the browser, and having the browser send…
Jeff Dege
  • 11,190
  • 22
  • 96
  • 165
0
votes
2 answers

Deserialization with base class model

I need to extract data from mongodb, but this data differs in coordinates, I can create a base-sub class structure and POST it to mongodb, but the coordinates do not come in the GET operation. public class Geometry { public string…
XLVII
  • 119
  • 9
0
votes
1 answer

How do I get System.Text.Json to deserialize objects into their original type?

I'm working with a POCO class in .NET 5.0 that I need to serialize and deserialize to and from the browser, and this is in a library where I don't want to have to tell the users which serializers they must use. So I'm trying to make it work with…
Jeff Dege
  • 11,190
  • 22
  • 96
  • 165
0
votes
1 answer

.net System.Text.Json property name based serialization

Is it possible to write a custom converter to serialize based on the name of the property? An example is to keep the time part of a DateTime type property if the property name ends with "DateTime", otherwise discard the time part. The converter…
zyq
  • 41
  • 9
0
votes
0 answers

parsing text that is a sequence of JSON objects without enclosing brackets (there is no root object) in .NET?

Suppose I have an input stream coming in that is a sequence of objects, like so: { "value" : 1} { "value" : 2} { "value" : 3} { "value" : 4} How can I deserialize these objects in C#? Using System.Text.Json is preferred, Newtonsoft is fine. It…
Frank Schwieterman
  • 24,142
  • 15
  • 92
  • 130
0
votes
1 answer

What properties/fields are included (System.Text.Json.JsonSerializer)?

Which of the following are included by JsonSerializer? Private/Protected/Internal Fields Private/Protected/Internal Properties Public Fields Public Properties Readonly Writeonly Read & Write
trinalbadger587
  • 1,905
  • 1
  • 18
  • 36
0
votes
0 answers

Debugger blows up in JsonElement.DebuggerDisplay.get

I'm writing my first project trying to use System.Text.Json in a .net core app. I'm getting a jsonl file with a particular structure, and my requirements are in effect to UNPIVOT/flatten an array of child objects in one object into a stream of…
user1664043
  • 695
  • 5
  • 14
0
votes
1 answer

Deserialize JSON encoded HTML code with System.Text.Json

I'm using C# to call a REST API which returns a JSON object containing HTML code. Here is an example of the object I'm interested in { "Body": "\r\n
nor0x
  • 1,213
  • 1
  • 15
  • 41
0
votes
1 answer

C# deserialize Json with ID nodes

How can I deserialize Json into C# objects that have ID's for the node keys? For example: { "people" : { "1": { "firstname": "jim", "lastname": "brown" }, "2": { "firstname": "kathy", "lastname": "jones" …
Ryan Langton
  • 6,294
  • 15
  • 53
  • 103
0
votes
1 answer

Setting property name to include @ in JSON using System.Text.Json

I need to send via REST (not including some other sensitive information): {"@Scope": "Local"} In the class file I JsonProperty for Json.Net serialization: [JsonProperty("@Scope")] public string Scope { get; set; } When putting together the json…
baddrivers
  • 25
  • 4