by pmelendez · 12y ago · 0 comments
"I Don’t Know".ToJson();
public string ToJson()
{
var s = new StringBuilder("{");
for (var i = 0; i < CustomField.CustomFieldOption.Count; i++)
{
var item = CustomField.CustomFieldOption[i];
s.Append("\"" + item.CustomFieldOptionId + "\"");
s.Append(":\"" + item.OptionName + "\"");
if (i < CustomField.CustomFieldOption.Count - 1)
{
s.Append(",");
}
}
s.Append("}");
return s.ToString();
}I notice that the two pieces of data actually going into the JSON are "CustomFieldOptionId" and "OptionName" -- which seem somewhat useless/obscure, but there could be a legitimate reason for that.
So yeah, I don't quite get it either. Most of the others are more obviously silly.
About 6 years ago I wrote something similar, but that was before newtonsoft.json was super popular.
var item = CustomField.CustomFieldOption[i];
Shouldn't that be the item to convert? This looks like something stuck onto a class to serialize to JSON.I might be missing the joke also :(