我正试图将一个C#对象序列化为Json对象,然后将其提交到Salesforce API并创建应用程序。目前,我已将C#对象序列化为Json字符串,但我需要它成为一个对象。
这是我的C#对象以及伴随的序列化:
Customer application = new Customer {
ProductDescription = "gors_descr " + tbDescription.Text,
Fname = "b_name_first " + tbFName.Text,
Lname = "b_name_last " + tbLName.Text
};
var json = new System.Web.Script.Serialization.JavaScriptSerializer();
string jsonString = json.Serialize(application);
string endPoint = token.instance_url + "/services/apexrest/submitApplication/";
string response = conn.HttpPost(endPoint, json, token);
Literal rLiteral = this.FindControl("resultLiteral") as Literal;
我需要将JSON字符串输出到JSON对象中。以下是我需要的示例:
"{ \"jsonCreditApplication\" : " +
"\"gors_descr\" : \"Appliances\", " +
"\"b_name_first\" : \"Marisol\", " +
"\"b_name_last\" : \"Testcase\", " +
"}";
这个硬编码的JSON字符串在一个对象内。目前,在C#对象中的值被输出为JSON字符串,但我需要将其输出为一个对象,以便Salesforce API接受提交。
我该如何将JSON字符串附加或插入到对象中?