I have a List that is converted to a string for JSON parsing. I need to replace 0 values with the word "null" since the API that I'm using accepts it rather than leaving it blank it the list.
I tried string replace "0," with "null," however this will not work when the end of the list value is 0.
public List<double> Message { get; set; }
public string jsonMessage
get {
string test = "";
if (this.Message!= null && this.Message.Count > 0)
{
test = String.Join(",", this.Message).Replace("0,","null,")
}
return test;
}
Message