Generating C# classes for tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2023 09:50 AM - edited 01-17-2023 03:28 AM
Hi,
Can anyone please tell me the quickest/safest way to generate C# entity classes for the various ServiceNow table (endpoints?) ?
I have gone down a bit of a rabbit hole in generating C# classes from the json response using online converters such as https://json2csharp.com/.
The problem I am finding (obvious with hindsight) is that a response that has 100 json elements will generate different class than a request that has 500 elements, because the online converter using the values it finds to work out the type.
An example is Incident.u_template, based on a low sample rate this is empty so is classed as a string, however based on 100 elements it looks to return an object.
My class looks like this:
Though on a large sample the online converter classifies it as an object.
public object UTemplate;
Full Incident class attached
Thanks