리플렉션을 사용하여 상속 여부, 공개 여부, 비공개 여부 등을 기준으로 멤버를 필터링 할 수 있습니다. 동일한 정렬을 수행 할 수있는 방법이 있습니까? JSon.NET을 사용하여 객체를 직렬화 할 때 필터링이 필요합니까?JSON에 직렬화 (Json.Net 사용). 상속받은 멤버를 무시하면서
내 코드 현재 :
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public void addRequestParameters<T>(string key, T SerializableRequestParameters)
{
//Serialize the object
string json = JsonConvert.SerializeObject(SerializableRequestParameters, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.All,
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
//Add it to an existing request (unrelated to this question)
((JObject)JSONRequest).Add(key, JToken.Parse(json));
}