/// <summary> /// Returns the json of this request /// We need to build it manually because it needs a specific structure /// TODO: Maybe there's a better way? /// </summary> /// <returns></returns> public string ToJson() { var parameters = new JArray(); parameters.Add(Params); // Add attributes if any exist if (Attributes.Any()) { parameters.Add(Attributes); } // Get JSON from filter if (RequestFilter.HasElements()) { // We need to add an empty attributes array if there are no attributes so that the filter parameter is respected if (!Attributes.Any()) { parameters.Add(new JArray()); } parameters.Add(RequestFilter.ToJson()); } var request = new JObject(new JProperty("method", Method), new JProperty("params", parameters), new JProperty("id", Id)); return(request.ToString()); }