ToJson() public method

public ToJson ( ) : Newtonsoft.Json.Linq.JObject
return Newtonsoft.Json.Linq.JObject
コード例 #1
0
        /// <summary>
        /// Gets the JSON representation of this object.
        /// </summary>
        /// <returns></returns>
        public string ToJson()
        {
            var json = SearchParams.ToJson();
            if (Query != null)
            {
                json.Add("query", Query.Export());
            }

            return json.ToString(Formatting.None);
        }
コード例 #2
0
        public void Sort_Adds_FieldNames_To_Output_Json()
        {
            var fields = new List<string> {"name", "-age"};

            var searchParams = new SearchParams();
            searchParams.Sort(fields.ToArray());

            var result = searchParams.ToJson().ToString(Formatting.None);

            var expected = JsonConvert.SerializeObject(new
            {
                ctl = new
                {
                    timeout = 75000
                },
                sort = fields
            }, Formatting.None);

            Assert.AreEqual(expected, result);
        }
コード例 #3
0
 /// <summary>
 /// Gets the JSON representation of this object.
 /// </summary>
 /// <returns></returns>
 public JObject ToJson()
 {
     return(SearchParams.ToJson());
 }