/// <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); }
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); }
/// <summary> /// Gets the JSON representation of this object. /// </summary> /// <returns></returns> public JObject ToJson() { return(SearchParams.ToJson()); }