[SOLVED] C# : How to Deserialize json data


This Content is from Stack Overflow. Question asked by ian

How to deserialized this type of json file


I want to get antenna, TID into variable

Thank you


This json is a collection so you’ll need to deserialise it to a collection:

// List<Hdr>, not Hdr
var listOfHrds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Hdr>>(json);
public class Hdr{
  public TagRead data { get; set; }


var json = File.ReadAllText("data.json");

var listOfHdrs = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Hdr>>(json);

Console.WriteLine(listOfHdrs[0].data.TID); // Output: e2806810200000040a0652c8

public class Hdr{
  public TagRead? data { get; set; }

public class TagRead{
     public string? TID { get; set; }

This Question was asked in StackOverflow by ian and Answered by tymtam It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?