title: Json.NET Custom ValueProvider to convert Objects into Guid
body: <p>I'm trying to create a custom ValueProvider for Json.NET that will skip serializing all the objects, and will just return a property of type Guid representing their primary Key instead (as a reference).</p>
  
  <p>Example:</p>
  
  <pre><code>jsonData: {
      myObject: {
          id: "23e23-2gg5-6y666556-y6yg33",
          property2: ""
      }
  }
  </code></pre>
  
  <p>Should become:</p>
  
  <pre><code>jsonData: {
      myObjectId: "23e23-2gg5-6y666556-y6yg33"
  }
  </code></pre>
  
  <p>This is the code I wrote so far. I'm very close to make it work, but in my <code>CustomValueProvider</code> I don't seem to be able to get the object values. How can I do that?</p>
  
  <pre><code>    private class CustomValueProvider : IValueProvider
      {
          private readonly MemberInfo _member;
  
          public CustomValueProvider(MemberInfo member)
          {
              _member = member;
          }
          public void SetValue(object target, object value)
          {
              throw new NotImplementedException();
          }
  
          public object GetValue(object target)
          {
              return // WHAT HERE??
          }
      }
  
      private class CustomResolver : CamelCasePropertyNamesContractResolver
      {
          protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
          {
              var jsonProperty = base.CreateProperty(member, memberSerialization);
  
              if (jsonProperty.PropertyType.IsClass &amp;&amp; jsonProperty.PropertyType != typeof(string))
              {
                  jsonProperty = new JsonProperty
                  {
                      PropertyName = member.Name.ToFirstCharLower() + "Id",
                      Readable = true,
                      ShouldSerialize = value =&gt; true,
                      PropertyType = typeof(Guid),
                      ValueProvider = new CustomValueProvider(member)
                  };
              }
  
              return jsonProperty;
          }
      }
  
      private static readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings
      {
          ContractResolver = new CustomResolver(),
          Formatting = Formatting.Indented
      };
  </code></pre>