title: How to serialize a dynamic object to a JSON string in dotnet core?
body: <p>I am passing a JSON payload to an API Controller, and one of the fields is dynamic because the field needs to be passed again as a JSON string to another API.  The dotnet core 3.1 middle layer shouldn't be concerned with typing, as the payload will change.</p>
  
  <p>This is the object that is passed into the API Controller:</p>
  
  <pre><code>    public class GitHubAction
      {
          [JsonProperty("Title")]
          public string Title { get; set; }
  
          [JsonProperty("Enabled")]
          [JsonConverter(typeof(BooleanParseStringConverter))]
          public bool Enabled { get; set; }
  
          [JsonProperty("Action")]
          [JsonConverter(typeof(ExpandoObjectConverter))]
          public dynamic Action { get; set; }
      }
  </code></pre>
  
  <p>Here is a picture of that <code>dynamic</code> object looks like in VSCode:</p>
  
  <p><a href="https://i.stack.imgur.com/Nippe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nippe.png" alt="enter image description here"></a></p>
  
  <p>When I use <code>JsonConvert.SerializeObject(x.Action);</code> the string result isn't being properly converted, but instead serializes to ValueKind: <code>"{\"ValueKind\":1}"</code>.  </p>
  
  <p>What I want to get is the action object value as a JSON string, which should look like <code>"{"createRepository":{"onboarding":{"service":{"organization":"foo","repositoryName":"foo-2-service","description":"A test service."}}}}"</code></p>
  
  <p>Is there a simple solution for serializing a dynamic object?</p>