title: Is there a dynamic way of including class name as property in JSON return value from web service
body: <p>I am writing a web service (c#, minimal api) for a front end application in Typescript. For type checking I want to include a type property in my JSON returned from the web service.</p>
  <p>Example:</p>
  <p>Following result expected in the front end</p>
  <pre><code>{
     &quot;name&quot;: &quot;Jason&quot;,
     &quot;type&quot;: &quot;User&quot;
  }
  </code></pre>
  <p>The user class in the backend will look like this</p>
  <pre><code>public class User {
      public string Name { get; set; }
  
      //I do not want to have this property in every class
      public string Type { 
          get {
              return &quot;User&quot;;
          }
      }
  }
  </code></pre>
  <p>This works fine, but I have to add the property Type to every single class in the web service. Is there a way to tell the JSON serializer to do it for me?</p>
  <pre><code>var builder = WebApplication.CreateBuilder(args);
  builder.Services.Configure&lt;JsonOptions&gt;(options =&gt;
  {
      //do something here to achieve a &quot;type&quot; property?
  });
  </code></pre>