private string _SerializeCustomMember(MemberInfo keyMemberInfo, object value, bool useTupleFormat) { JSONNodeAttribute attribute = Util.GetAttribute <JSONNodeAttribute> (keyMemberInfo); NodeOptions options = attribute == null ? NodeOptions.Default : attribute.options; if (!options.IsSerialized()) { return(null); } string valueString = Serialize(value, options); if (valueString != null || options.ShouldSerializeNull()) { if (useTupleFormat) { return(valueString == null ? _kUndefined : valueString); } string key = (attribute != null && attribute.key != null) ? attribute.key : keyMemberInfo.Name; return(_SerializeString(key) + ":" + (valueString == null ? _kUndefined : valueString)); } else { return(null); } }
/// <summary> /// Serializes <c>null</c> if NodeOptions.SerializeNull is used or /// returns <c>null</c> otherwise. Null can be serialized as /// "null" or "undefined" according to the value of #useUndefinedForNull. /// </summary> public string SerializeNull(NodeOptions options) { return(options.ShouldSerializeNull() ? (useUndefinedForNull ? _kUndefined : _kNull) : null); }