Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenEU-Gesetz zur Cyber-Resilienz ist in Kraft - Netzpalaver(21.09.2026 um 20:29 Uhr)
Malware / Trojaner / VirenMeta Muse AI app flaw lets local malware redirect dictation traffic(21.09.2026 um 21:59 Uhr)
IT Security NachrichteniPhone 18 Pro (Max): Nutzer melden plötzliche Abstürze durch Face ID(21.09.2026 um 21:18 Uhr)
IT Security DownloadsEs wird Zeit, Word zu löschen(21.09.2026 um 21:53 Uhr)
IT NachrichtenAI can't outprompt a shortage of power, water, and land(21.09.2026 um 18:35 Uhr)
IT NachrichtenLondon neocloud Nscale takes its $1B loss to Wall Street(21.09.2026 um 19:15 Uhr)
IT Security NachrichtenEU-Gesetz zur Cyber-Resilienz ist in Kraft - Netzpalaver(21.09.2026 um 20:29 Uhr)
Malware / Trojaner / VirenMeta Muse AI app flaw lets local malware redirect dictation traffic(21.09.2026 um 21:59 Uhr)
IT Security NachrichteniPhone 18 Pro (Max): Nutzer melden plötzliche Abstürze durch Face ID(21.09.2026 um 21:18 Uhr)
IT Security DownloadsEs wird Zeit, Word zu löschen(21.09.2026 um 21:53 Uhr)
IT NachrichtenAI can't outprompt a shortage of power, water, and land(21.09.2026 um 18:35 Uhr)
IT NachrichtenLondon neocloud Nscale takes its $1B loss to Wall Street(21.09.2026 um 19:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Import specific properties from JSON

Introduction Learn how to read a json string with known properties and remove unwanted properties, followed by deserializing to a strongly typed class. From incoming to desired data type For this demonstration, the following…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Introduction



Learn how to read a json string with known properties and remove unwanted properties, followed by deserializing to a strongly typed class.






From incoming to desired data type



For this demonstration, the following data is incoming data with an extra property, Age, and two properties, Name and Last, which need to be FirstName and LastName.




[
{
"Id": 1,
"Name": "Mary",
"Last": "Jones",
"Age": 22
},
{
"Id": 2,
"Name": "John",
"Last": "Burger",
"Age": 44
},
{
"Id": 3,
"Name": "Anne",
"Last": "Adams",
"Age": 33
},
{
"Id": 4,
"Name": "Paul",
"Last": "Smith",
"Age": 29
},
{
"Id": 5,
"Name": "Lucy",
"Last": "Brown",
"Age": 25
}
]






The class to import data into.




public class Person
{
public int Id { get; set; }
[JsonPropertyName("Name")]
public string FirstName { get; set; }
[JsonPropertyName("Last")]
public string LastName { get; set; }
}









Aliasing properties



JsonPropertyName is used to alias from property names in json to what is in the class.






Removing unwanted properties



This is a simple process, read in a json file with the correct format followed iterating the array and for each item remove one or more properties. Here only one property is being removed.




var jsonArray = JsonNode.Parse(File.ReadAllText("peopleIncoming.json"))!.AsArray();

foreach (var item in jsonArray)
{
JsonObject obj = item!.AsObject();
obj.Remove("Age");
}






Next, place the modified json into a variable and write the json to a file.




var updatedJson = jsonArray.ToJsonString(Indented);

DisplayUpdatedJsonPanel(updatedJson);

Console.WriteLine();

File.WriteAllText("People.json", updatedJson);






Indented definition




public static JsonSerializerOptions Indented => new() { WriteIndented = true };






Deserializing to the Person class




var people = JsonSerializer.Deserialize<Person[]>(updatedJson);






The following screenshot is from a sample project that is included.



Output from sample project






Summary



With the provided instructions, it is easy to import json data into a desired format.






See also



C# System.Text.Json



Source code

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Import specific properties from JSON

Thematisch verwandte Begriffe: Import, specific, properties, from · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94494 | jshERP through 3.6 contains a tenant isolation bypass vulnerability that…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick