C#来格式化http客户端的主体


{
"name": "group1",
"userData": "user-provided data attached to the person group.",
"recognitionModel": "recognition_03"
}

如果我需要在http客户端调用中传递上面的主体,我该如何在C#中格式化它?

也许你可以在这里找到你的anwser:

public void JsonStringExample()
{
string example1 = @"{
""name"": ""group1"",
""userData"": ""user-provided data attached to the person group."",
""recognitionModel"": ""recognition_03""
}";
string example2 = "{"
+ " "name": "group1","
+ " "userData": "user-provided data attached to the person group.","
+ " "recognitionModel": "recognition_03""
+ "}";
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("{");
stringBuilder.AppendLine("  "name": "group1",");
stringBuilder.AppendLine("  "userData": "user-provided data attached to the person group.",");
stringBuilder.AppendLine("  "recognitionModel": "recognition_03"");
stringBuilder.AppendLine("}");
string example3 = stringBuilder.ToString();
string exmaple4 = String.Join(
"rn",
new string[]
{
"{",
"   "name": "group1",",
"   "userData": "user-provided data attached to the person group.",",
"   "recognitionModel": "recognition_03"",
"}"
}
);
}

最新更新