0

This are my models:

 public class Object
 {
     [JsonProperty(PropertyName = "test1")]
     public string Test1 { get; set; }

     [JsonProperty(PropertyName = "test2")]
     public string Test2 { get; set; }

     [JsonProperty(PropertyName = "_id")]
     public ID Id { get; set; }
 }

 public class ID
 {
     [JsonProperty(PropertyName = "$id")]
     public string Id { get; set; }
 }

When I debug it show every value correctly, but after the JsonConvert. Id is empty. What am I doing wrong here?

Json body:

 "test1: "sometext",
 "test2": "sometext",
  "_id": {
    "$id": "thisisanidstring"
  }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Bayern
  • 330
  • 3
  • 20

1 Answers1

0

This question is already there Have a look.

Json.NET uses $id as a reserved word to help it deal with object references.

Community
  • 1
  • 1
Aizaz Ahmed
  • 210
  • 1
  • 6