title: Json.net how to serialize object as value
body: <p>I've pored through the docs, StackOverflow, etc., can't seem to find this...</p>
  
  <p>What I want to do is serialize/deserialize a simple value-type of object as a value, not an object, as so:</p>
  
  <pre><code>public class IPAddress
  {
      byte[] bytes;
  
      public override string ToString() {... etc.
  }
  
  public class SomeOuterObject
  {
      string stringValue;
      IPAddress ipValue;
  }
  
  IPAddress ip = new IPAddress("192.168.1.2");
  var obj = new SomeOuterObject() {stringValue = "Some String", ipValue = ip};
  string json = JsonConverter.SerializeObject(obj);
  </code></pre>
  
  <p>What I want is for the json to serialize like this:</p>
  
  <pre><code>// json = {"someString":"Some String","ipValue":"192.168.1.2"} &lt;- value serialized as value, not subobject
  </code></pre>
  
  <p>Not where the ip becomes a nested object, ex:</p>
  
  <pre><code>// json = {"someString":"Some String","ipValue":{"value":"192.168.1.2"}}
  </code></pre>
  
  <p>Does anyone know how to do this? Thanks! (P.S. I am bolting Json serialization on a large hairy legacy .NET codebase, so I can't really change any existing types, but I can augment/factor/decorate them to facilitate Json serialization.)</p>