本文整理汇总了C#中JsonObject.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.SetValue方法的具体用法?C# JsonObject.SetValue怎么用?C# JsonObject.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateHtml
public override void GenerateHtml()
{
JsonObject output = new JsonObject();
string sProfile = Hm.Request("profile");
if (!Str.IsEmpty(sProfile))
{
CCProfile prf = CC.Current.Profiles[sProfile];
if (prf != null)
{
JsonArray sarr = output.SetArray("Scopes") as JsonArray;
foreach (CCScope scope in prf.Scopes)
{
sarr.EltAdd(scope.Name);
}
JsonArray arr = output.SetArray("MetaDataKeys") as JsonArray;
List<XDoc> MetaDataKeys = prf.Doc.EltList("MetaDataDef");
foreach (XDoc metakey in MetaDataKeys)
{
if (bool.Parse(metakey.Value("Active")))
{
JsonObject key = arr.EltAddObject() as JsonObject;
key.Set("Name", metakey.Value("EntityName"));
key.Set("MaxDisplay", int.Parse(metakey.Value("Max")));
key.Set("MinimumOccurrence", int.Parse(metakey.Value("Threshold")));
}
}
JsonArray relatedarr = output.SetArray("RelatedTerms") as JsonArray;
List<XDoc> RelatedKeys = prf.Doc.EltList("RelatedTermsDef");
foreach (XDoc metakey in RelatedKeys)
{
if (bool.Parse(metakey.Value("Active")))
{
JsonObject key = relatedarr.EltAddObject() as JsonObject;
key.Set("Name", metakey.Value("EntityName"));
key.Set("MaxDisplay", int.Parse(metakey.Value("Max")));
key.Set("MinimumOccurrence", int.Parse(metakey.Value("Threshold")));
}
}
JsonArray peoplearr = output.SetArray("PeopleDataKeys") as JsonArray;
List<XDoc> PeopleDataKeys = prf.Doc.EltList("PeopleDataDef");
foreach (XDoc pmetakey in PeopleDataKeys)
{
if (bool.Parse(pmetakey.Value("Active")))
{
JsonObject key = peoplearr.EltAddObject() as JsonObject;
key.Set("Name", pmetakey.Value("EntityName"));
key.Set("MaxDisplay", int.Parse(pmetakey.Value("Max")));
key.Set("MinimumOccurrence", int.Parse(pmetakey.Value("Threshold")));
}
}
JsonArray langarr = output.SetArray("LanguageOptions") as JsonArray;
List<XDoc> Languages = prf.Doc.EltList("LanguageOptions");
foreach (XDoc metakey in Languages )
{
if (bool.Parse(metakey.Value("Active")))
{
JsonObject key = langarr.EltAddObject() as JsonObject;
key.Set("label", metakey.Value("LanguageName"));
key.Set("value", metakey.Value("LanguageValue"));
}
}
}
output.SetValue("ChatterPollID", prf.Doc.Value("ChatterPollID"));
output.SetValue("FeedbackGroupId", prf.Doc.Value("FeedbackGroupID"));
output.SetValue("BestBetGroupId", prf.Doc.Value("BestBetGroupID"));
output.SetValue("MaxAuthors", prf.Doc.Value("MaxAuthors"));
output.SetValue("SessionTimeout", prf.Doc.Value("SessionTimeOut"));
output.SetValue("MaxRecentSearches", prf.Doc.Value("MaxRecentSearches"));
}
Hm.SetContentType("application/json");
Hm.Write(Json.Serialize(output, true));
if (!Str.IsEmpty(Hm.Request("callback")))
Hm.Write(")");
}
示例2: CreateJsonRecords
// Helper method to read the items in a dictionary and make a JSON object from them.
private JsonObject[] CreateJsonRecords(Dictionary<string, double> inListDictionary)
{
JsonObject[] jsonRecordsArray = new JsonObject[inListDictionary.Count];
int i = 0;
// Loop through dictionary.
foreach (KeyValuePair<string, double> kvp in inListDictionary)
{
// Get the current key and value.
string currentKey = kvp.Key.ToString();
string currentValue = kvp.Value.ToString();
// Add the key and value to a JSON object.
JsonObject currentKeyValue = new JsonObject();
currentKeyValue.AddString(m_mapLayerNameToQuery, currentKey);
currentKeyValue.AddString("value", currentValue);
// Add the record object to an array.
jsonRecordsArray.SetValue(currentKeyValue, i);
i++;
}
return jsonRecordsArray;
}
示例3: GenerateHtml
public override void GenerateHtml()
{
string _to = Hm.RequestForm("to");
string _from = Hm.RequestForm("from");
string _subject = Hm.RequestForm("subject");
string _body = Hm.RequestForm("body");
//string _index = Hm.Request("index");
//string _status = Hm.Request("status");
//string _id = Hm.Request("id");
//Query the Approvals Index
//EngineClient client = EngineClientsPool.FromPoolByIndex(_index);
//try
//{
// string sql = Str.And("select * from ", _index, " where id = ", Str.SqlValue(_id));
// using (Cursor cursor = client.ExecCursor(sql))
// {
// while (!cursor.End())
// {
// _to = Str.IfEmpty(_to, AribaEmail);
// _from = Str.IfEmpty(_from, cursor.GetColumn("sourcevarchar3"));
// _subject = Str.IfEmpty(_subject, _status + " " + Str.Split(cursor.GetColumn("title"), ':')[0]);
// StringBuilder Body = new StringBuilder();
// Body.AppendLine("[:Begin Comments section. Enter your comments starting on the next line:]");
// Body.AppendLine("Submitted via the Approvals App");
// Body.AppendLine("[:End Comments section:]");
// Body.AppendLine("");
// Body.AppendLine("IMPORTANT: Send this message to approve this request.");
// Body.AppendLine("");
// Body.AppendLine("Do not edit or delete the text below this line.");
// if (_status.ToLower() != "deny")
//Approve URL
// Body.AppendLine("[x] " + cursor.GetColumn("sourcevarchar51"));
// else
//Deny URL
// Body.AppendLine("[x] " + cursor.GetColumn("sourcevarchar52"));
// _body = Body.ToString();
// cursor.MoveNext();
// }
// }
//}
//finally
//{
// EngineClientsPool.ToPool(client);
//}
JsonObject output = new JsonObject();
output.SetValue("To", _to);
output.SetValue("From", _from);
output.SetValue("Subject", _subject);
output.SetValue("Body", _body);
output.SetValue("Response", SendEmail(_to, _from, _subject, _body));
Hm.SetContentType("application/json");
Hm.Write(Json.Serialize(output, true));
if (!Str.IsEmpty(Hm.Request("callback")))
Hm.Write(")");
}