Quote:
I got error
And you didn't think it was important to tell us
what error you got?
Your JSON represents a single object with a property called
features
. That property contains an array of objects, each of which contains a property called
attributes
. That property contains a single object which seems to match your
LRSSegment
class.
To deserialize that, you need your C# classes to match the JSON structure:
public class Root
{
[JsonProperty("features")]
public Feature[] Features { get; set; }
}
public partial class Feature
{
[JsonProperty("attributes")]
public LRSSegment Attributes { get; set; }
}
Root lrsSeg = JsonSerializer.Deserialize<Root>(jString);
If in doubt, there are plenty of tools you can use to generate C# classes from JSON - for example,
quicktype.io[
^].
Visual Studio also has a "paste special" option to "paste JSON as classes":
Paste JSON or XML as classes - Visual Studio (Windows) | Microsoft Learn[
^]