lundi 16 septembre 2019

Can i create a json example with empty values from only an objects type?

we are doing some stuff with webhooks and events. I wanna create an example of a json payload based on the type of the event send to the webhook.

Lets say i have a class like this:

public class TestClass{
    public int Id {get;set;}
}

Now what i would like, is to be able to create something like

{
    "id": 0
}

just from knowing typeof(TestClass).

I do not want to create instances of my objects, because some of them are rather complex and has all sorts of parameter requirements.

I just want an json representation without any of the values filed in.

Any ideas?





Aucun commentaire:

Enregistrer un commentaire