2

Let's say I have such a JSON:

{
   "A": {
      "variable": "sth"
   }
}

I could write the code below for the purpose of serialization and schema generation:

public class A
{
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    public string variable { get; set; }
}

public class RootObject
{
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    public A A { get; set; }
}

Unfortunately, there is this variable part which is always different. Is it possible to write classes in such a way that would allow me to serialize and generate schema with ease? I could just update a certain field before serialization / schema generation and voila! It would use a certain string as the variable.

Thanks! :)

ebvtrnog
  • 4,167
  • 4
  • 31
  • 59

0 Answers0