本文整理汇总了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

▲ 点赞 11 ▼
        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

▲ 点赞 10 ▼
        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

▲ 点赞 5 ▼
        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

示例4: Import

▲ 点赞 2 ▼
        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

▲ 点赞 1 ▼
        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

示例6: GetActivePlayers

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
        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

示例8: LoadData

▲ 点赞 1 ▼
 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

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
         /// <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

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
        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

▲ 点赞 1 ▼
 // 클라이언트가 접속시 호출
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
 

C# JObject.Add方法代码示例的更多相关文章

  1. axios get及post方法代码示例&&方法封装

    axios get及post方法代码示例 get方法: show: function(){ //get方式 //赋值给变量self var self = this; var url = "h ...

  2. MFC编辑框接收数据动态更新与刷新方法代码示例-如何让编辑框内容实时更新

    MFC编辑框接收数据动态更新与刷新方法代码示例-如何让编辑框内容实时更新 关键代码: //发送数据通知 //from txwtech@163.com LRESULT CCommSampleDlg::O ...

  3. [deviceone开发]-动态添加组件add方法的示例

    一.简介 这个示例详细介绍ALayout的add方法的使用(原理也适用于Linearlayout),以及add上去的新ui和已有的ui如何数据交换,初学者推荐.二.效果图 三.相关下载 https:/ ...

  4. ref:关于JAVA中一些安全漏洞示例说明及如何规避方法代码示例总结分享

    ref:http://www.xwood.net/_site_domain_/_root/5870/5874/t_c268166.html 标签:安全,漏洞,健壮,java,SQL注入,SS及CSRF ...

  5. php发送get、post请求的6种方法代码示例

    本文主要展示了php发送get.post请求的6种方法的代码示例,分别为使用file_get_contents .fopen.fsockopen.curl来发送GET和POST请求,代码如下: 方法1 ...

  6. SQL注入原理与解决方法代码示例

    一.什么是sql注入? 1.什么是sql注入呢? 所谓SQL注入,就是通过把SQL命令插入到Web表单递交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令,比如先前的很多影视网 ...

  7. 25个JavaScript数组方法代码示例

    摘要: 通过代码掌握数组方法. 原文:通过实现25个数组方法来理解及高效使用数组方法(长文,建议收藏) 译者:前端小智 Fundebug经授权转载,版权归原作者所有. 要在给定数组上使用方法,只需要通 ...

  8. php一些单选、复选框的默认选择方法(示例)

    转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...

  9. 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好

    HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...

  10. laravel 框架配置404等异常页面的方法详解(代码示例)

    本篇文章给大家带来的内容是关于laravel 框架配置404等异常页面的方法详解(代码示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 在Laravel中所有的异常都由Handl ...

随机推荐

  1. 双向链表的基本实现【数据结构与算法—TypeScript 实现】

    笔记整理自 coderwhy 『TypeScript 高阶数据结构与算法』课程 双向链表:拥有两个指针方向的链表 DoublyNode 结构: prev:指向上一个节点 value:节点值 next: ...

  2. HDC2021技术分论坛:HarmonyOS低代码开发介绍

    作者:sunyuhui,wangxiaoyan,华为2012实验室软件IDE专家 什么是低代码开发?低代码开发主要特点有哪些?如何利用低代码开发原子化服务?本文带你一探究竟~ 一.什么是Harmony ...

  3. SilentEye qsnctf wp

    题目附件(注:文件名为Luminous.jpg) 根据题目提示,使用SilentEye工具 将图片使用SilentEye打开 使用左下角的Decode解密功能 猜测密码为文件名,输入并开始解密 将被加 ...

  4. C++ 类方法解析:内外定义、参数、访问控制与静态方法详解

    C++ 类方法 类方法,也称为成员函数,是属于类的函数.它们用于操作或查询类数据,并封装在类定义中.类方法可以分为两种类型: 类内定义方法: 直接在类定义内部声明和定义方法. 类外定义方法: 在类定义 ...

  5. 面试题 02.07(Java). 链表相交(简单)

    题目: 本题与:力扣160相交链表 一致 给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点.如果两个链表没有交点,返回 null . 图示两个链表在节点 c ...

  6. 剑指offer29(Java)-顺时针打印矩阵(简单)

    题目: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字. 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]]输出:[1,2,3,6,9,8,7,4,5 ...

  7. 力扣442(java)-数组中重复的数据(中等)

    题目: 给你一个长度为 n 的整数数组 nums ,其中 nums 的所有整数都在范围 [1, n] 内,且每个整数出现 一次 或 两次 .请你找出所有出现 两次 的整数,并以数组形式返回. 你必须设 ...

  8. 暑期集训 Day7 —— 模拟赛复盘

    ${\color{Green} \mathrm{Problem\ 1 :最优包含 }} $ 发现是 DP,于是开始设计状态:DP[i][j] 表示前一个字符串匹配到位置 i,后一个匹配到 j 的最少修 ...

  9. MaxCompute执行引擎核心技术DAG揭秘

    ​简介: 作为业界少有的EB级数据分布式平台,MaxCompute每天支撑上千万个分布式作业的运行.这些作业特点各异,既有包含数十万计算节点的超大型作业,也有中小规模的分布式作业.不同用户对于不同规模 ...

  10. OSI模型之数据链路层

    一.简介 数据链路层在物理层提供服务的基础上向网络层提供服务,其最基本的服务是将源自网络层的数据可靠地传输到相邻节点的目标机网络层.其主要作用是加强物理层传输原始比特流的功能,将物理层提供的可能出错的 ...