I'm developing my own JSON-to-POCO framework. The way I'm doing it is, that I created the class of a Json-schema that looks like this:
public class JsonSchema
{
public string type { get; set; }
public string title { get; set; }
public string description { get; set; }
public Dictionary<string, JsonSchema> properties { get; set; }
public JsonSchema items { get; set; }
public string id { get; set; }
public List<string> required { get; set; }
public bool ispartial = true;
}
and deserializing the schema to have my object(s) so I can work with it perfectly.
Everything is working fine for now, I'm getting my generated C#-file. But only if I don't add $ref
s to my json. (Since it's much less code to add a reference in json instead of copy-paste the classes I want to support them)
What I need to do is, adding the $ref
to my class. Problem here is, I cannot add an attribute like
public string $ref { get; set; }
to my code.
Any idea what I could do?
The problem was also, that you cannot deserialize $id and $ref with default settings. This was solved by reading this nice post here: JsonConvert.DeserializeObject<> (string) returns null value for $id property