public string Serialize(ISerializableObject objectToSerialize, string jsonFields) { if (objectToSerialize == null) { throw new ArgumentNullException(nameof(objectToSerialize)); } IList <string> fieldsList = null; if (!string.IsNullOrEmpty(jsonFields)) { var primaryPropertyName = objectToSerialize.GetPrimaryPropertyName(); fieldsList = GetPropertiesIntoList(jsonFields); fieldsList.Add(primaryPropertyName); } var json = Serialize(objectToSerialize, fieldsList); return(json); }
public string Serialize(ISerializableObject objectToSerialize, string jsonFields) { if (objectToSerialize == null) { throw new ArgumentNullException("objectToSerialize"); } IList <string> fieldsList = null; if (!string.IsNullOrEmpty(jsonFields)) { string primaryPropertyName = objectToSerialize.GetPrimaryPropertyName(); fieldsList = GetPropertiesIntoList(jsonFields); // Always add the root manually fieldsList.Add(primaryPropertyName); } string json = Serialize(objectToSerialize, fieldsList); return(json); }