本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.Add方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.Add方法的具体用法?C# JObject.Add怎么用?C# JObject.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FormatPropertyInJson
public void FormatPropertyInJson()
{
JObject query = new JObject();
JProperty orderProp = new JProperty("order", "breadth_first");
query.Add(orderProp);
JObject returnFilter = new JObject();
returnFilter.Add("body", new JValue("position.endNode().getProperty('name').toLowerCase().contains('t')"));
returnFilter.Add("language", new JValue("javascript"));
query.Add("return_filter", new JValue(returnFilter.ToString()));
JObject pruneEval = new JObject();
pruneEval.Add("body", new JValue("position.length() > 10"));
pruneEval.Add("language", new JValue("javascript"));
query.Add("prune_evaluator", pruneEval.ToString());
query.Add("uniqueness", new JValue("node_global"));
JArray relationships = new JArray();
JObject relationShip1 = new JObject();
relationShip1.Add("direction", new JValue("all"));
relationShip1.Add("type", new JValue("knows"));
relationships.Add(relationShip1);
JObject relationShip2 = new JObject();
relationShip2.Add("direction", new JValue("all"));
relationShip2.Add("type", new JValue("loves"));
relationships.Add(relationShip2);
query.Add("relationships", relationships.ToString());
//arr.Add(
Console.WriteLine(query.ToString());
//Assert.AreEqual(@"""order"" : ""breadth_first""", jobject.ToString());
}
开发者ID:sonyarouje,项目名称:Neo4jD,代码行数:35,代码来源:DataFormatTest.cs
示例2: ToJSON
public static JObject ToJSON(this QueryResult myQueryResult)
{
// root element...
var _Query = new JObject();
// query --------------------------------
_Query.Add(new JProperty("query", myQueryResult.Query));
// result -------------------------------
_Query.Add(new JProperty("result", myQueryResult.ResultType.ToString()));
// duration -----------------------------
_Query.Add(new JProperty("duration", new JArray(myQueryResult.Duration, "ms")));
// warnings -----------------------------
_Query.Add(new JProperty("warnings", new JArray(
from _Warning in myQueryResult.Warnings
select new JObject(
new JProperty("code", _Warning.GetType().ToString()),
new JProperty("description", _Warning.ToString())
))));
// errors -------------------------------
_Query.Add(new JProperty("errors", new JArray(
from _Error in myQueryResult.Errors
select new JObject(
new JProperty("code", _Error.GetType().ToString()),
new JProperty("description", _Error.ToString())
))));
// results ------------------------------
_Query.Add(new JProperty("results", new JArray(GetJObjectsFromResult(myQueryResult.Vertices))));
return _Query;
}
开发者ID:ipbi,项目名称:sones,代码行数:35,代码来源:JSON_IO_Extensions.cs
示例3: GetTestRestQuery
private string GetTestRestQuery()
{
JObject query = new JObject();
JProperty orderProp = new JProperty("order", "breadth_first");
query.Add(orderProp);
JObject returnFilter = new JObject();
returnFilter.Add("body", new JValue("position.endNode().getProperty('FirstName').toLowerCase().contains('sony')"));
returnFilter.Add("language", new JValue("javascript"));
JProperty filter = new JProperty("return_filter", returnFilter);
query.Add(filter);
JArray relationships = new JArray();
JObject relationShip1 = new JObject();
relationShip1.Add("direction", new JValue("out"));
relationShip1.Add("type", new JValue("wife"));
relationships.Add(relationShip1);
JObject relationShip2 = new JObject();
relationShip2.Add("direction", new JValue("all"));
relationShip2.Add("type", new JValue("loves"));
relationships.Add(relationShip2);
JProperty relationShipProp = new JProperty("relationships", relationships);
query.Add(relationShipProp);
JProperty uniqueness = new JProperty("uniqueness", "node_global");
query.Add(uniqueness);
JProperty maxDepth = new JProperty("max_depth", 2);
query.Add(maxDepth);
return query.ToString();
}
开发者ID:sonyarouje,项目名称:Neo4jD,代码行数:32,代码来源:RESTApi_Test.cs
<iframe data-google-container-id="a!4" data-google-query-id="CMvWyZzng4ADFRcEKgodUNsGeA" data-load-complete="true" frameborder="0" height="0" id="aswift_3" marginheight="0" marginwidth="0" name="aswift_3" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-9584489059513758&output=html&h=186&slotname=7774727988&adk=1796063218&adf=605524869&pi=t.ma~as.7774727988&w=744&fwrn=4&lmt=1671250784&rafmt=11&format=744x186&url=https%3A%2F%2Fvimsky.com%2Fexamples%2Fdetail%2Fcsharp-ex-Newtonsoft.Json.Linq-JObject-Add-method.html&wgl=1&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTE0LjAuMTgyMy42NyIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjAxIl0sWyJNaWNyb3NvZnQgRWRnZSIsIjExNC4wLjE4MjMuNjciXV0sMF0.&dt=1688980648446&bpp=1&bdt=636&idt=752&shv=r20230705&mjsv=m202307050101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Ded4f8fd31c53186e-2256c2a6b1b400fd%3AT%3D1688541464%3ART%3D1688541464%3AS%3DALNI_MYXS4F2t4akVCpqzRMSN7_geVxu0w&gpic=UID%3D00000c9696146cd3%3AT%3D1688541464%3ART%3D1688541464%3AS%3DALNI_Ma-n1eXC6tE-AOLAjHPcgYJidW5nQ&prev_fmts=0x0%2C744x280%2C744x186&nras=1&correlator=5631610452342&frm=20&pv=1&ga_vid=1764164644.1688980649&ga_sid=1688980649&ga_hid=1025499933&ga_fc=0&rplot=4&u_tz=480&u_his=1&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=24&u_sd=1&dmc=8&adx=396&ady=3335&biw=1850&bih=969&scr_x=0&scr_y=0&eid=44759876%2C44759927%2C44759837%2C31075642%2C31075816%2C31075832%2C44788442&oid=2&pvsid=4350564119605450&tmod=1209300773&wsm=1&uas=0&nvt=3&ref=https%3A%2F%2Fcn.bing.com%2F&fc=1920&brdim=0%2C0%2C0%2C0%2C1920%2C0%2C1920%2C1040%2C1865%2C969&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=4&uci=a!4&btvi=2&fsb=1&xpc=siwoySOpsy&p=https%3A//vimsky.com&dtd=760" width="744"></iframe>
示例4: Import
public ActionResult Import(string savedFileName)
{
var jo = new JObject();
string result;
try
{
var fileName = string.Concat(Server.MapPath(fileSavedPath), "/", savedFileName);
var importZipCodes = new List<TaiwanZipCode>();
var helper = new ImportDataHelper();
var checkResult = helper.CheckImportData(fileName, importZipCodes);
jo.Add("Result", checkResult.Success);
jo.Add("Msg", checkResult.Success ? string.Empty : checkResult.ErrorMessage);
if (checkResult.Success)
{
//儲存匯入的資料
helper.SaveImportData(importZipCodes);
}
result = JsonConvert.SerializeObject(jo);
}
catch (Exception ex)
{
throw;
}
return Content(result, "application/json");
}
开发者ID:hsinchenhuang,项目名称:MVC-Excel-Import-Export,代码行数:30,代码来源:ZipCodeController.cs
示例5: addToApplicationSearch
public void addToApplicationSearch(Keymap keymap, string search)
{
if (this.isInApplicationSearch(keymap))
{
return;
}
JToken level1 = this.jsonObj.GetValue("Applications");
if (level1 == null)
{
this.jsonObj.Add("Applications", new JArray());
}
level1 = this.jsonObj.GetValue("Applications");
JArray array = (JArray)level1;
JObject newObj = new JObject();
newObj.Add("Search", search);
newObj.Add("Keymap", keymap.Filename);
array.Add(newObj);
this.jsonObj.Remove("Applications");
this.jsonObj.Add("Applications", array);
save();
}
开发者ID:marquinio007,项目名称:Touchmote,代码行数:25,代码来源:KeymapSettings.cs
<iframe data-google-container-id="a!5" data-google-query-id="CJT-lqbng4ADFWnKTAIdUXUH8w" data-load-complete="true" frameborder="0" height="186" id="aswift_4" marginheight="0" marginwidth="0" name="aswift_4" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-9584489059513758&output=html&h=186&slotname=7774727988&adk=1796063218&adf=2708018588&pi=t.ma~as.7774727988&w=744&fwrn=4&lmt=1671250784&rafmt=11&format=744x186&url=https%3A%2F%2Fvimsky.com%2Fexamples%2Fdetail%2Fcsharp-ex-Newtonsoft.Json.Linq-JObject-Add-method.html&wgl=1&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTE0LjAuMTgyMy42NyIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjAxIl0sWyJNaWNyb3NvZnQgRWRnZSIsIjExNC4wLjE4MjMuNjciXV0sMF0.&dt=1688980648447&bpp=1&bdt=637&idt=769&shv=r20230705&mjsv=m202307050101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Ded4f8fd31c53186e-2256c2a6b1b400fd%3AT%3D1688541464%3ART%3D1688980648%3AS%3DALNI_MYXS4F2t4akVCpqzRMSN7_geVxu0w&gpic=UID%3D00000c9696146cd3%3AT%3D1688541464%3ART%3D1688980648%3AS%3DALNI_Ma-n1eXC6tE-AOLAjHPcgYJidW5nQ&prev_fmts=0x0%2C744x280%2C744x186%2C744x186%2C300x600%2C300x600&nras=1&correlator=5631610452342&frm=20&pv=1&ga_vid=1764164644.1688980649&ga_sid=1688980649&ga_hid=1025499933&ga_fc=0&rplot=4&u_tz=480&u_his=1&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=24&u_sd=1&dmc=8&adx=396&ady=4717&biw=1850&bih=969&scr_x=0&scr_y=859&eid=44759876%2C44759927%2C44759837%2C31075642%2C31075816%2C31075832%2C44788442&oid=2&psts=ABnkTfA7gaOhoTXSaIou_Fj3kLnQ0c6Cdr2oee1O-LGc4y2lvkzf1ylW2077sVzFnrFqWHJh9LUARRfxM6XZ5B29tgE9JQFG%2CABnkTfBwlCOqEXTL7jwopiR4u3GfgD1PnEb695qcmYzevDQJCc7sjr4vqe3Lu0SeErVKD6loRZs3r9ArNKjMPolX2LP41GEV%2CABnkTfDjKx4oK0zYhdFNbO9YhcgfnRiSPnNYQM9R4fNJ7Is3ANjhtVZW89-cy2YjZSDPVyCCtIOzp8VplSVjyegUBCiOAP0%2CABnkTfCPPM2zBXwhV-F_a4Um84nscWlIPyS4CDKvmhIhufgJ7tmNvTKBwxcflSzMj8CIxW3JyqhniUmQKmpZEJzZS-KKkmYG&pvsid=4350564119605450&tmod=1209300773&wsm=1&uas=3&nvt=3&ref=https%3A%2F%2Fcn.bing.com%2F&fc=1920&brdim=0%2C0%2C0%2C0%2C1920%2C0%2C1920%2C1040%2C1865%2C969&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=5&uci=a!5&btvi=4&fsb=1&xpc=B5DbB46QbO&p=https%3A//vimsky.com&dtd=20899" width="744"></iframe>
示例6: GetActivePlayers
public List<ActivePlayer> GetActivePlayers(XbmcSettings settings)
{
try
{
var postJson = new JObject();
postJson.Add(new JProperty("jsonrpc", "2.0"));
postJson.Add(new JProperty("method", "Player.GetActivePlayers"));
postJson.Add(new JProperty("id", 10));
var response = _httpProvider.PostCommand(settings.Address, settings.Username, settings.Password, postJson.ToString());
if (CheckForError(response))
return new List<ActivePlayer>();
var result = Json.Deserialize<ActivePlayersEdenResult>(response);
return result.Result;
}
catch (Exception ex)
{
_logger.DebugException(ex.Message, ex);
}
return new List<ActivePlayer>();
}
开发者ID:niel,项目名称:NzbDrone,代码行数:26,代码来源:JsonApiProvider.cs
示例7: Index
public ActionResult Index(string errorMessage)
{
var client = new CouchClient("dannylane.iriscouch.com", 6984, "dannylane", "adminpass", true, AuthenticationType.Cookie);
var udb = client.GetDatabase("testing");
JObject jObject = new JObject();
jObject.Add("DateTime", DateTime.UtcNow);
jObject.Add("UserHostAddress", Request.UserHostAddress);
jObject.Add("UserHostName", Request.UserHostName);
// jObject.Add("UserLanguages", Request.UserLanguages.ToString());
foreach (var param in Request.QueryString.AllKeys)
{
jObject.Add(param, Request.QueryString[param]);
}
foreach (var param in Request.Headers.AllKeys)
{
jObject.Add(param, Request.Headers[param]);
}
var info = new LoveSeat.Document(jObject);
udb.SaveDocument(info);
return File("favicon.ico","image");
}
开发者ID:dannylane,项目名称:ErrorBucket.io,代码行数:27,代码来源:LogController.cs
<iframe data-google-container-id="a!6" data-google-query-id="CKnX_6_ng4ADFckDKgodLfIOxQ" data-load-complete="true" frameborder="0" height="186" id="aswift_5" marginheight="0" marginwidth="0" name="aswift_5" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-9584489059513758&output=html&h=186&slotname=7774727988&adk=1796063218&adf=789333073&pi=t.ma~as.7774727988&w=744&fwrn=4&lmt=1671250784&rafmt=11&format=744x186&url=https%3A%2F%2Fvimsky.com%2Fexamples%2Fdetail%2Fcsharp-ex-Newtonsoft.Json.Linq-JObject-Add-method.html&wgl=1&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTE0LjAuMTgyMy42NyIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjAxIl0sWyJNaWNyb3NvZnQgRWRnZSIsIjExNC4wLjE4MjMuNjciXV0sMF0.&dt=1688980648447&bpp=1&bdt=637&idt=775&shv=r20230705&mjsv=m202307050101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Ded4f8fd31c53186e-2256c2a6b1b400fd%3AT%3D1688541464%3ART%3D1688980648%3AS%3DALNI_MYXS4F2t4akVCpqzRMSN7_geVxu0w&gpic=UID%3D00000c9696146cd3%3AT%3D1688541464%3ART%3D1688980648%3AS%3DALNI_Ma-n1eXC6tE-AOLAjHPcgYJidW5nQ&prev_fmts=0x0%2C744x280%2C744x186%2C744x186%2C300x600%2C300x600%2C744x186&nras=1&correlator=5631610452342&frm=20&pv=1&ga_vid=1764164644.1688980649&ga_sid=1688980649&ga_hid=1025499933&ga_fc=0&rplot=4&u_tz=480&u_his=1&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=24&u_sd=1&dmc=8&adx=396&ady=6277&biw=1850&bih=969&scr_x=0&scr_y=2415&eid=44759876%2C44759927%2C44759837%2C31075642%2C31075816%2C31075832%2C44788442&oid=2&psts=ABnkTfA7gaOhoTXSaIou_Fj3kLnQ0c6Cdr2oee1O-LGc4y2lvkzf1ylW2077sVzFnrFqWHJh9LUARRfxM6XZ5B29tgE9JQFG%2CABnkTfBwlCOqEXTL7jwopiR4u3GfgD1PnEb695qcmYzevDQJCc7sjr4vqe3Lu0SeErVKD6loRZs3r9ArNKjMPolX2LP41GEV%2CABnkTfDjKx4oK0zYhdFNbO9YhcgfnRiSPnNYQM9R4fNJ7Is3ANjhtVZW89-cy2YjZSDPVyCCtIOzp8VplSVjyegUBCiOAP0%2CABnkTfCPPM2zBXwhV-F_a4Um84nscWlIPyS4CDKvmhIhufgJ7tmNvTKBwxcflSzMj8CIxW3JyqhniUmQKmpZEJzZS-KKkmYG%2CABnkTfDGTgd24QKlBQ1fYuLLkNxujX2-Alqt_ANWSWMUvug_IXUgsHOvqiRiZ_JPzvvCxncubRA1ulCrN9nxN_BNKukrMSl1&pvsid=4350564119605450&tmod=1209300773&wsm=1&uas=3&nvt=3&ref=https%3A%2F%2Fcn.bing.com%2F&fc=1920&brdim=0%2C0%2C0%2C0%2C1920%2C0%2C1920%2C1040%2C1865%2C969&vis=1&rsz=%7C%7CoeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=6&uci=a!6&btvi=5&fsb=1&xpc=3nup5FISFt&p=https%3A//vimsky.com&dtd=41487" width="744"></iframe>
示例8: LoadData
private void LoadData()
{
JObject jo = new JObject();
jo.Add("BoxMargin", "0");
jo.Add("BoxFlex", 1);
UserInfoControl5.Properties = jo.ToString(Formatting.None);
}
开发者ID:jinwmmail,项目名称:RDFNew,代码行数:7,代码来源:userinfo2.aspx.cs
示例9: Login
public static async Task<string> Login()
{
Console.WriteLine("--- LOGIN ---");
Console.Write("Username: ");
string gebruiker = Console.ReadLine();
Username = gebruiker;
Console.Write("Password: ");
string password = Console.ReadLine();
JObject jsonObj = new JObject();
jsonObj.Add("gebruiker", gebruiker);
jsonObj.Add("ww", SHA1Util.SHA1HashStringForUTF8String(password));
string result = await RequestUtil.Post(LinkBuilder.Build(new string[] { "login" }), jsonObj.ToString());
string key = String.Empty;
try
{
key = JObject.Parse(result)["SLEUTEL"].ToString();
Logger.Log("ApiUtil", "Key aqquired: " + key, Logger.LogLevel.Info);
} catch(Exception e)
{
Logger.Log("ApiUtil", result, Logger.LogLevel.Error);
}
return key;
}
开发者ID:RSDT,项目名称:JotiApiT,代码行数:29,代码来源:ApiUtil.cs
示例10: GetDirectory
/// <summary>
/// Get the directories and files in the given directory
/// </summary>
public async Task<XBMCRPC.Files.GetDirectoryResponse> GetDirectory(string directory=null, XBMCRPC.Files.Media media=0, XBMCRPC.List.Fields.Files properties=null, XBMCRPC.List.Sort sort=null, XBMCRPC.List.Limits limits=null)
{
var jArgs = new JObject();
if (directory != null)
{
var jpropdirectory = JToken.FromObject(directory, _client.Serializer);
jArgs.Add(new JProperty("directory", jpropdirectory));
}
if (media != null)
{
var jpropmedia = JToken.FromObject(media, _client.Serializer);
jArgs.Add(new JProperty("media", jpropmedia));
}
if (properties != null)
{
var jpropproperties = JToken.FromObject(properties, _client.Serializer);
jArgs.Add(new JProperty("properties", jpropproperties));
}
if (sort != null)
{
var jpropsort = JToken.FromObject(sort, _client.Serializer);
jArgs.Add(new JProperty("sort", jpropsort));
}
if (limits != null)
{
var jproplimits = JToken.FromObject(limits, _client.Serializer);
jArgs.Add(new JProperty("limits", jproplimits));
}
return await _client.GetData<XBMCRPC.Files.GetDirectoryResponse>("Files.GetDirectory", jArgs);
}
开发者ID:Cocotus,项目名称:Ember-MM-Newscraper,代码行数:33,代码来源:Files.cs
示例11: ConvertRecursively
private static void ConvertRecursively(IResource currentResource, JObject node, JsonSerializer serializer)
{
if (currentResource == null)
{
return;
}
var currentResourceType = currentResource.GetType();
var readableProperties = GetReadablePropertyInfos(currentResourceType);
var nonResourceProperties = readableProperties.Where(IsNeitherResourceOrReservedProperty).ToList();
var resourceProperties = readableProperties.Where(IsResourceProperty).ToList();
node.Add(ReservedPropertyNames.Relations, JObject.FromObject(currentResource.Relations, serializer));
var embeddedResourceObject = new JObject();
node.Add(ReservedPropertyNames.EmbeddedResources, embeddedResourceObject);
foreach (var resourceProperty in resourceProperties)
{
var embeddedResourceNodeValue = new JObject();
ConvertRecursively((IResource)resourceProperty.GetValue(currentResource), embeddedResourceNodeValue, serializer);
embeddedResourceObject.Add(ToCamelCase(resourceProperty.Name), embeddedResourceNodeValue);
}
if (IsCollectionResourceType(currentResourceType))
{
var currentResourceDynamic = (dynamic) currentResource;
var jArray = new JArray();
string name = "";
foreach (IResource resourceItem in currentResourceDynamic.Items)
{
var embeddedResourceNodeValue = new JObject();
ConvertRecursively(resourceItem, embeddedResourceNodeValue, serializer);
jArray.Add(embeddedResourceNodeValue);
name = resourceItem.GetType().Name;
}
// Remove the "Resource" by convention.
if (name.EndsWith("Resource"))
{
name = name.Remove(name.LastIndexOf("Resource", StringComparison.Ordinal));
}
embeddedResourceObject.Add(ToCamelCase(name), jArray);
}
foreach (var nonResourceProperty in nonResourceProperties)
{
var value = nonResourceProperty.GetValue(currentResource);
if (value != null && value.GetType().GetTypeInfo().IsClass && value.GetType() != typeof(string))
{
node.Add(ToCamelCase(nonResourceProperty.Name), JToken.FromObject(value, serializer));
}
else
{
node.Add(ToCamelCase(nonResourceProperty.Name), new JValue(value));
}
}
}
开发者ID:olohmann,项目名称:Lohmann.HALight,代码行数:60,代码来源:ResourceConverter.cs
示例12: testMsgContentAndExtras
public void testMsgContentAndExtras()
{
Message message = Message.content("msgContent");
message.AddExtras("key1", "value1");
message.AddExtras("key2", 222);
message.AddExtras("key3", false);
message.Check();
JObject json = new JObject();
json.Add("msg_content",JToken.FromObject("msgContent"));
JObject extras = new JObject();
extras.Add("key1", JToken.FromObject("value1"));
extras.Add("key2", JToken.FromObject(222));
extras.Add("key3", JToken.FromObject(false));
json.Add("extras", extras);
var jSetting = new JsonSerializerSettings();
jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
var jsonString = JsonConvert.SerializeObject(message, jSetting);
var jsonObject = json.ToString(Formatting.None);
var fromJson = JsonConvert.DeserializeObject<Message>(jsonObject);
Assert.AreEqual(jsonObject, jsonString);
}
开发者ID:wcgh,项目名称:Zichanguanli-Server-for-C-code,代码行数:25,代码来源:MessageTest.cs
示例13: processer
public Newtonsoft.Json.Linq.JArray processer(string jsonStr)
{
String userID=null;
String pTypeID=null;
JArray jsa = JArray.Parse(jsonStr);
JObject json = JObject.Parse(jsa[0].ToString());
pTypeID = json["pTypeID"].ToString();
userID = json["userID"].ToString();
Dict_固定资产Dao dd=new Dict_固定资产Dao();
//例如是3
List<Model> list=dd.getAllFatherTypeByID(pTypeID);
JArray jsaa=new JArray();
foreach(Model m in list){
JObject j=new JObject();
j.Add("代码", ((Dict_固定资产Model)m).get代码());
j.Add("名称", ((Dict_固定资产Model)m).get名称());
j.Add("层级码",((Dict_固定资产Model)m).get层级码());
jsaa.Add(j);
}
return jsaa;
}
开发者ID:wcgh,项目名称:Zichanguanli-Server-for-C-code,代码行数:27,代码来源:GetFatherFenleihaoProcesser.cs
示例14: SerializeMessage
public JObject SerializeMessage(Message message)
{
JObject messageObject = new JObject();
messageObject.Add("jsonrpc", JToken.FromObject("2.0"));
if (message.MessageType == MessageType.Request)
{
messageObject.Add("id", JToken.FromObject(message.Id));
messageObject.Add("method", message.Method);
messageObject.Add("params", message.Contents);
}
else if (message.MessageType == MessageType.Event)
{
messageObject.Add("method", message.Method);
messageObject.Add("params", message.Contents);
}
else if (message.MessageType == MessageType.Response)
{
messageObject.Add("id", JToken.FromObject(message.Id));
if (message.Error != null)
{
// Write error
messageObject.Add("error", message.Error);
}
else
{
// Write result
messageObject.Add("result", message.Contents);
}
}
return messageObject;
}
开发者ID:juvchan,项目名称:PowerShellEditorServices,代码行数:35,代码来源:JsonRpcMessageSerializer.cs
示例15: Connected
// 클라이언트가 접속시 호출
public void Connected(IReceiveContext channel)
{
JObject o = new JObject();
o.Add("name", "test");
o.Add("value", i++);
channel.GetChannel().SendMessage(o);
}
开发者ID:shlee322,项目名称:Netronics,代码行数:8,代码来源:Client.cs
标签:JProperty,示例,C#,代码,JObject,Add,var,new From: https://www.cnblogs.com/webenh/p/17541734.html