Newtonsoft.Json 去掉$id

The custom ContractResolver setting overrides the PreserveReferencesHandling setting.

In your implementation of DefaultContractResolver/IContractResolver, add this;

public override JsonContract ResolveContract(Type type) {
    var contract = base.ResolveContract(type);
    contract.IsReference = false;
    return contract;
}

This behaves similarly to the PreserveReferencesHandling.None setting without a custom ContractResolver

http://www.cnblogs.com/yanweidie/p/4605212.html

猜你喜欢

转载自www.cnblogs.com/zhutiehan/p/9114974.html