public void EnumSerializer_HasNoODataType_ForNonFullMetadata(string acceptHeader) { // Arrange & Act HttpResponseMessage response = GetEnumResponse(acceptHeader); // Assert response.EnsureSuccessStatusCode(); JObject customer = response.Content.ReadAsAsync <JObject>().Result; Assert.False(customer.Values().Contains("*****@*****.**")); Assert.False(customer.Values().Contains("*****@*****.**")); }
public void Load(JObject content) { foreach (var obj in content.Values()) { Panel.Children.Add(new SoundControl(obj as JObject, tree, SoundPath, this)); } }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var jqGridData = (JqGridData)value; writer.WriteStartObject(); WriteProperty(jqGridData.Configuration.Total, jqGridData.Total, writer); WriteProperty(jqGridData.Configuration.Page, jqGridData.Page, writer); WriteProperty(jqGridData.Configuration.Records, jqGridData.Records, writer); writer.WritePropertyName(jqGridData.Configuration.Root); var hasId = HasId(jqGridData); JArray jArray = JArray.FromObject(jqGridData.Rows); JArray newjArray = new JArray(); foreach (JToken jToken in jArray) { JObject jObject = (JObject)jToken; JObject newjObject = new JObject(); if (hasId && jqGridData.Configuration.IncludeId) { JToken id = GetId(jObject); newjObject.Add(jqGridData.Configuration.Id, id); if (jqGridData.Configuration.ExcludeIdFromCell) { jObject.Remove("Id"); } } IJEnumerable <JToken> values = jObject.Values(); newjObject.Add(new JProperty(jqGridData.Configuration.Cell, new JArray(values))); newjArray.Add(newjObject); } newjArray.WriteTo(writer); writer.WriteEndObject(); }
private string _url = "http://www.7980mt.com/smsCode/getCode";//这里请替换为您的状态监控页 public SendSMSVC_API(string app_id, string app_secret, string access_token, string numTo, int?exptime) { APP_ID = app_id; APP_SECRET = app_secret; Access_Token = access_token; Method = RequestType.post; SMSVCToken_API smsvctoken_api = new SMSVCToken_API(app_id, app_secret, access_token); string result = smsvctoken_api.Result; try { JObject jo = JObject.Parse(result); _token = jo.Values("token").ToString(); _phoneNumTo = numTo; if (exptime != null) { _exptime = exptime; } _timestamp = Utility.GetCurrentDate(); PrepareParam(); } catch (Exception e) { throw e; } }
/// <summary> /// Loads all the prices for tradeable items from the OSB price data API and stores them in /// a dictionary. /// </summary> public void LoadItemPrices(bool forceRefresh = false) { if (!Utility.FileExists("prices.json") || Utility.ShouldRefreshPrices(forceRefresh)) { try { browser.ExpectNonHtmlResponse = true; browser.Navigate(osbPriceLink, true); browser.ExpectNonHtmlResponse = false; JObject priceDataAsJson = (JObject)JToken.Parse(browser.InnerText); IEnumerable <JToken> itemPricesJson = priceDataAsJson.Values(); ItemPrices = itemPricesJson.ToDictionary(itemToken => itemToken.Value <int>("id"), CreateItemPrice); Utility.SaveObjectToJson("prices.json", "OfflineJson", ItemPrices); Properties.Settings.Default.TimeSinceLastRefresh = DateTime.Now; Properties.Settings.Default.Save(); } catch (WebException) { TryLoadItemPricesFromCache(); } } else { TryLoadItemPricesFromCache(); } }
private Object doLast(PipelineContext ctx, Object value) { if (value == null) { return(null); } Array arr = value as Array; if (arr != null) { return((arr.Length == 0) ? null : arr.GetValue(arr.Length - 1)); } JArray jarr = value as JArray; if (jarr != null) { return((jarr.Count == 0) ? null : jarr[jarr.Count - 1]); } JObject jobj = value as JObject; if (jobj != null) { return((jobj.Count == 0) ? null : jobj.Values().Last()); } return(ConvertScalar(ctx, value)); }
private void SetProperties() { _jClassInfo.Properties = new List <JInfo>(); JClassCreater classCreater = new JClassCreater(); JArrayCreater arrayCreater = new JArrayCreater(); List <JToken> jTokens = _jObject.Values().ToList(); foreach (var item in jTokens) { if (item.Type.ToString().Equals(JsonType.Object)) { JClassInfo temp = classCreater.Create((JObject)item); temp.Parent = _jClassInfo; //temp.Type = _jClassInfo.Name + (_jClassInfo.Properties.Count(x => x.Type == "class") + 1); _jClassInfo.Properties.Add(temp); } else if (item.Type.ToString().Equals(JsonType.Array)) { JArray temp = (JArray)item; _jClassInfo.Properties.Add(arrayCreater.Create(temp)); } else { _jClassInfo.Properties.Add(new JValueInfo { Name = Converter.PathToName(item.Path), Type = Converter.TypeStringConverter(item.Type.ToString()) }); } } }
private IEnumerable <RemoteCustomFieldValue> GetCustomFieldValuesFromObject(JObject jObject) { return(jObject.Values <JProperty>() .Where(field => field.Name.StartsWith("customfield", StringComparison.InvariantCulture) && field.Value.Type != JTokenType.Null) .Select(field => { var customFieldType = GetCustomFieldType(field.Name); var remoteCustomFieldValue = new RemoteCustomFieldValue() { customfieldId = field.Name }; if (this._customFieldSerializers.ContainsKey(customFieldType)) { remoteCustomFieldValue.values = this._customFieldSerializers[customFieldType].FromJson(field.Value); } else { remoteCustomFieldValue.values = new string[1] { field.Value.ToString() }; } return remoteCustomFieldValue; })); }
/// <summary> /// Parses WSE XTestStep to get payload /// </summary> /// <param name="xTestStep">WSE XTestStep</param> /// <param name="tql">tql to get root json object from request/reponse object</param> /// <returns>payload</returns> public string Parse(XTestStep xTestStep, string tql = "") { try { if (xTestStep == null) { return(string.Empty); } XTestStepValue jsonObject = xTestStep.Search(tql).Cast <XTestStepValue>().FirstOrDefault( x => x.ModuleAttribute.BusinessType == "JsonObject" || x.ModuleAttribute.BusinessType == "JsonArray"); if (jsonObject != null) { JArray arrayObject = new JArray(); JObject plainObject = CommonUtilities.ConstructJsonStructure(jsonObject, new JObject()); if (jsonObject.ModuleAttribute.BusinessType == "JsonObject") { return(Convert.ToString(plainObject)); } arrayObject.Add(plainObject.Values()); return(Convert.ToString(arrayObject)); } } catch (Exception e) { FileLogger.Instance.Error( $"Failed to create Json payload for request :{xTestStep?.Name}", e); } return(string.Empty); }
/// <summary> /// construct json payload for Api modules /// </summary> /// <param name="rawRequestPayload">WSE XTestStepValues</param> /// <param name="jObject">json payload</param> /// <returns>json payload</returns> public static JObject ConstructJsonStructure(XTestStepValue rawRequestPayload, JObject jObject) { try { foreach (var testStepValue in rawRequestPayload.SubValues) { if (testStepValue.ModuleAttribute.BusinessType == "JsonValue") { jObject.Add(testStepValue.Name, testStepValue.Value); } else if (testStepValue.ModuleAttribute.BusinessType == "JsonObject") { JObject nestedObject = new JObject(); nestedObject = ConstructJsonStructure(testStepValue, nestedObject); jObject.Add(testStepValue.Name, nestedObject); } else if (testStepValue.ModuleAttribute.BusinessType == "JsonArray") { JArray arrayAttributes = new JArray(); JObject arrayObject = new JObject(); arrayObject = ConstructJsonStructure(testStepValue, arrayObject); arrayAttributes.Add(arrayObject.Values()); jObject.Add(testStepValue.Name, arrayAttributes); } } } catch (Exception ex) { FileLogger.Instance.Error(ex.Message); } return(jObject); }
/// <summary> /// Gets the global configuration data. /// </summary> /// <param name="clientID">The client ID of the extension</param> /// <param name="clientSecret">The client secret of the extension</param> /// <param name="ownerID">The owner user ID of the extension</param> /// <returns>The global configuration data for the extension</returns> public static async Task <ConfigurationModel> GetGlobalConfiguration(string clientID, string clientSecret, string ownerID) { Validator.ValidateString(clientID, "clientID"); Validator.ValidateString(clientSecret, "clientSecret"); Validator.ValidateString(ownerID, "ownerID"); using (AdvancedHttpClient client = TwitchExtensionService.GetHttpClient(clientID, clientSecret, ownerID, null)) { HttpResponseMessage response = await client.GetAsync($"https://api.twitch.tv/extensions/{clientID}/configurations/segments/global"); if (response.IsSuccessStatusCode) { JObject jobj = await response.ProcessJObjectResponse(); if (jobj != null && jobj.Count > 0) { ConfigurationResultModel result = jobj.Values().First().ToObject <ConfigurationResultModel>(); if (result != null) { return(new ConfigurationModel(result)); } } return(null); } else { return(null); } } }
public override void OnHandle(IStore store, string collection, JObject command, JObject document) { IObjectStore st = store.GetCollection(collection); if (document.Type == JTokenType.Array) { var documents = document.Values(); if (documents != null) { foreach (JObject d in documents) { var k = d.Property(DocumentMetadata.IdPropertyName); if (k != null) { st.Set((string)k, d); } } } } else { var k = document.Property(DocumentMetadata.IdPropertyName); if (k != null) { st.Set((string)k, document); } } }
public IActionResult GetDetails(Customer coordinate) { HttpWebRequest webRequest = WebRequest.Create($"https://developers.zomato.com/api/v2.1/restaurant?res_id={coordinate.restaurant_id}") as HttpWebRequest; HttpWebResponse webResponse = null; webRequest.Headers.Add("X-Zomato-API-Key", apikey); //you can get KeyValue by registering with Zomato. webRequest.Method = "GET"; webResponse = (HttpWebResponse)webRequest.GetResponse(); Customer details = new Customer() { }; if (webResponse.StatusCode == HttpStatusCode.OK) { StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string responseData = responseReader.ReadToEnd(); JObject restaurant = JsonConvert.DeserializeObject <JObject>(responseData); var names = restaurant.Values().Select(x => x.ToObject <object>()).ToList(); var test = restaurant["location"]; var test2 = test["address"]; var test3 = restaurant["name"]; var test4 = restaurant["photos_url"]; var test5 = restaurant["average_cost_for_two"]; var test6 = restaurant["user_rating"]; var test7 = test6["rating_text"]; details.Address = Convert.ToString(test2); details.RestaurantName = Convert.ToString(test3); details.ReviewText = Convert.ToString(test7); details.PhotoURL = Convert.ToString(test4); } return(View(details)); }
public IActionResult GetCityZomato(Customer coordinate) { HttpWebRequest webRequest = WebRequest.Create($"https://developers.zomato.com/api/v2.1/geocode?lat={coordinate.Latitude}&lon={coordinate.Longitude}") as HttpWebRequest; HttpWebResponse webResponse = null; webRequest.Headers.Add("X-Zomato-API-Key", apikey); //you can get KeyValue by registering with Zomato. webRequest.Method = "GET"; webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.StatusCode == HttpStatusCode.OK) { StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string responseData = responseReader.ReadToEnd(); JObject coordinates = JsonConvert.DeserializeObject <JObject>(responseData); var names = coordinates.Values().Select(x => x.ToObject <object>()).ToList(); var test = coordinates.GetValue("location"); var test2 = test["city_id"]; var test3 = test["entity_id"]; var test4 = test["entity_type"]; var test5 = test["longitude"]; var test6 = test["latitude"]; coordinate.city_id = Convert.ToInt32(test2); coordinate.entity_id = Convert.ToInt32(test3); coordinate.entity_type = Convert.ToString(test4); } return(RedirectToAction("GetCuisine", "Restaurants", coordinate)); }
public void Load(JObject content) { foreach (var obj in content.Values()) { Outputs.Add(new Output(obj as JObject, tree, this)); } }
public IActionResult GetCity(string location) { HttpWebRequest webRequest = WebRequest.Create($"https://maps.googleapis.com/maps/api/geocode/json?address={location}&sensor=false&key=AIzaSyDPd_kaIJibv8PaW5y-FmYqXnxuD1jRT14") as HttpWebRequest; HttpWebResponse webResponse = null; webRequest.Method = "GET"; webResponse = (HttpWebResponse)webRequest.GetResponse(); Customer coordinate = new Customer() { }; if (webResponse.StatusCode == HttpStatusCode.OK) { StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string responseData = responseReader.ReadToEnd(); JObject coordinates = JsonConvert.DeserializeObject <JObject>(responseData); var names = coordinates.Values().Select(x => x.ToObject <object>()).ToList(); var test = coordinates["results"]; var test2 = test[0]; var test3 = test2["geometry"]; var test4 = test3["location"]; var test5 = test4["lat"]; var test6 = test4["lng"]; coordinate.Latitude = Convert.ToDouble(test5); coordinate.Longitude = Convert.ToDouble(test6); } return(RedirectToAction("GetCityZomato", "Restaurants", coordinate)); }
private static string GetNameFromJson(string file) { try { using (ZipArchive za = ZipFile.OpenRead(file)) { var entry = za.Entries.FirstOrDefault(x => x.Name.Equals("info.json")); if (entry != null) { using (var stream = new StreamReader(entry.Open())) { JObject obj = JsonConvert.DeserializeObject(stream.ReadToEnd()) as JObject; var saveName = obj.Values().FirstOrDefault(x => x.Path == "Title"); if (saveName != null) { return(saveName.ToString()); } } } } } catch { //continue to return the filename if we fail for any reason } return(null); }
internal UmbracoGalleryBlock(string type, JObject obj, JObject data) : base(type, obj) { Items = ( from JObject child in data.Values() select new UmbracoMediaItem(child) ).ToArray(); }
public async Task <DetailedMatch> GetDetailedMatch(string matchId) { try { string queryString = QueryBuilder(BASE_ADDRESS, "IDOTA2Match_570/GetMatchDetails/V001/", _keyString, "&match_id=", matchId); string content = await GetStringAsync(queryString); var apiResult = JsonConvert.DeserializeObject <ApiResult <DetailedMatch> >(content); //Fix structure since Valves API is giving some strange values that we can't parse JObject dynamicContent = JObject.Parse(content); IEnumerable <JToken> players = dynamicContent.Values().First()["players"].Children(); string propertyStartName = "item_"; foreach (JObject player in players) { int slot = player["player_slot"].Value <int>(); MatchPlayer matchPlayer = apiResult.Result.Players.FirstOrDefault(p => p.PlayerSlot == slot); matchPlayer.Items = new List <SlotItem>(); foreach (var property in player.Properties().Where(prop => prop.Name.StartsWith(propertyStartName))) { var i = int.Parse(property.Name.Replace(propertyStartName, "")); var itemId = property.Value.Value <int>(); matchPlayer.Items.Add(new SlotItem(i, itemId)); } } return(apiResult.Result); } catch (Exception) { throw; } }
/// <summary> /// Gets value of specified key /// If contains "error", throws exception /// </summary> /// <param name="content"></param> /// <param name="key"></param> /// <returns></returns> public static string GetValueOfKey(string content, string key) { var error = JObject.Parse(content)[Params.error]; if (null != error) { throw new Exception(error.ToString()); } //Get value without recursion JObject jObjectParsed = JObject.Parse(content); JToken valueParsed = jObjectParsed[key]; if (null != valueParsed) { return(valueParsed.ToString()); } //recursion else { foreach (JToken jToken in jObjectParsed.Values()) { string result = GetValueOfTokenKey(jToken, key); if (null != result) { return(result); } } } return(null); }
public static List <Dictionary <string, string> > GetApiAttributes(string sourceUrl) { List <Dictionary <string, string> > response = new List <Dictionary <string, string> >(); var client = new WebClient(); var rawResponse = client.DownloadString(sourceUrl); var jsonResponse = JsonConvert.DeserializeObject(rawResponse); JObject jObject = JObject.Parse(jsonResponse.ToString()); List <JToken> jList = new List <JToken>(); foreach (var j in jObject.Values().ToArray()) { jList.Add(j); } foreach (var items in jList) { foreach (var item in items.Children <JObject>()) { var itemDict = new Dictionary <string, string>(); foreach (JProperty prop in item.Properties()) { itemDict.Add(prop.Name, prop.Value.ToString()); } response.Add(itemDict); } } return(response); }
public async Task TestAuthentication() { var userCredentials = new Configuration.UserCredentials() { UserName = "******", Password = "******" }; string authToken = String.Empty; //context = new DefaultHttpContext(); var tokenRequest = new HttpRequestMessage( HttpMethod.Post, appConfiguration.Value.UrlTokenAPI + "api/Users/Token"); var tokenClient = httpClientFactory.CreateClient(); Dictionary <string, string> keyvalues = new Dictionary <string, string>(); keyvalues.Add("UserName", userCredentials.UserName); keyvalues.Add("Password", userCredentials.Password); var content = JsonConvert.SerializeObject(keyvalues); StringContent stringContent = new StringContent(content, System.Text.Encoding.UTF8, "application/json"); var tokenResponse = await tokenClient.PostAsync(tokenRequest.RequestUri, stringContent); if (tokenResponse.IsSuccessStatusCode) { string respContent = tokenResponse.Content.ReadAsStringAsync().Result; JObject tokenObjects = JsonConvert.DeserializeObject <JObject>(respContent); foreach (JToken tokenObject in tokenObjects.Values()) { if (tokenObject.Values("values") != null) { authToken = tokenObject.Value <string>("token").ToString(); break; } } } if (String.IsNullOrEmpty(authToken)) { Assert.Fail("Authentication token cannot be obtained. Check credentials."); } else { Assert.Pass("Authentication token successfully obtained."); } lastResult = authToken; }
/// <summary> /// 从对象添加 /// </summary> /// <param name="table"></param> /// <param name="value"></param> private static void AddFromJObject(DataTable table, JObject value) { foreach (var kv in value) { table.Columns.Add(kv.Key); } table.Rows.Add(value.Values().ToArray()); }
public async Task <GetTeamInfoResult> GetTeamInfoByTeamId(int startAtTeamId = -1, int teamsRequested = -1) { try { StringBuilder extra = new StringBuilder(); if (startAtTeamId != -1) { extra.AppendFormat("{0}{1}", "&start_at_team_id=", startAtTeamId); } if (teamsRequested != -1) { extra.AppendFormat("{0}{1}", "&teams_requested=", teamsRequested); } string query = QueryBuilder(BASE_ADDRESS, "IDOTA2Match_570/GetTeamInfoByTeamID/v001/", _keyString, extra.ToString()); string content = await GetStringAsync(query); var apiResult = JsonConvert.DeserializeObject <ApiResult <GetTeamInfoResult> >(content); JObject dynamicContent = JObject.Parse(content); IEnumerable <JToken> teams = dynamicContent.Values().First()["teams"].Children(); string playerStart = "player_"; string leagueStart = "league_id"; foreach (var jToken in teams) { var team = (JObject)jToken; int teamId = team["team_id"].Value <int>(); Team currentTeam = apiResult.Result.Teams.FirstOrDefault(q => q.TeamId == teamId); currentTeam.PlayerAccountIds = new List <long>(); currentTeam.LeagueIds = new List <long>(); foreach (var property in team.Properties().Where(prop => prop.Name.StartsWith(playerStart) || prop.Name.StartsWith(leagueStart))) { if (property.Name.StartsWith(playerStart)) { currentTeam.PlayerAccountIds.Add(property.Value.Value <long>()); } if (property.Name.StartsWith(leagueStart)) { currentTeam.LeagueIds.Add(property.Value.Value <long>()); } } } return(apiResult.Result); } catch (Exception) { throw; } }
/// <summary> /// Given a JObject of facets in an Elasticsearch structure materialize them as the /// desired CLR objects determined by the projector. /// </summary> /// <typeparam name="T">Type of CLR objects to be materialized.</typeparam> /// <param name="facets">Elasticsearch formatted list of facets.</param> /// <returns>List of materialized CLR objects using the projector.</returns> internal List <T> Many <T>(JObject facets) { var termFacetsValues = facets.Values() .Where(x => termsFacetTypes.Contains(x["_type"].ToString())) .ToList(); return(termFacetsValues.Any() ? FlattenTermsToAggregateRows(termFacetsValues).Select(projector).Cast <T>().ToList() : new List <T>()); }
public List <TwitchVideoResolution> ParseResolutions(JObject resolutionsJson, JObject fpsJson) { List <TwitchVideoResolution> resolutions = new List <TwitchVideoResolution>(); Dictionary <string, string> fpsList = new Dictionary <string, string>(); if (fpsJson != null) { foreach (JProperty fps in fpsJson.Values <JProperty>()) { fpsList.Add(fps.Name, ((int)Math.Round(fps.Value.Value <double>(), 0)).ToString()); } } if (resolutionsJson != null) { foreach (JProperty resolution in resolutionsJson.Values <JProperty>()) { string quality = resolution.Name; string value = resolution.Value.Value <string>(); switch (quality) { case "chunked": resolutions.Add(new TwitchVideoResolution(VideoQuality.Source, value, fpsList.ContainsKey("chunked") ? fpsList["chunked"] : null)); break; case "high": resolutions.Add(new TwitchVideoResolution(VideoQuality.High, value, fpsList.ContainsKey("high") ? fpsList["high"] : null)); break; case "medium": resolutions.Add(new TwitchVideoResolution(VideoQuality.Medium, value, fpsList.ContainsKey("medium") ? fpsList["medium"] : null)); break; case "low": resolutions.Add(new TwitchVideoResolution(VideoQuality.Low, value, fpsList.ContainsKey("low") ? fpsList["low"] : null)); break; case "mobile": resolutions.Add(new TwitchVideoResolution(VideoQuality.Mobile, value, fpsList.ContainsKey("mobile") ? fpsList["mobile"] : null)); break; } } } if (!resolutions.Any()) { resolutions.Add(new TwitchVideoResolution(VideoQuality.Source, null, null)); } resolutions = resolutions.OrderBy(r => this.orderMap[r.VideoQuality]).ToList(); return(resolutions); }
private static void LoadClusters(JObject root) { foreach (JObject cluster in root.Values()) { ZclCluster cl = new ZclCluster(); cl.Name = cluster.Path; cl.Id = cluster["id"].Value <ushort>(); var attributes = cluster["attrId"]; foreach (JProperty attr in attributes) { ZclAttribute zclAttribute = new ZclAttribute(); zclAttribute.Name = attr.Name; foreach (JObject info in attr) { zclAttribute.Id = info.GetValue("id").Value <ushort>(); zclAttribute.DataType = (DataType)info.GetValue("type").Value <int>(); } cl.Attributes.Add(zclAttribute); } JToken reqCmds = cluster["cmd"]; foreach (JProperty cmd in reqCmds) { ZclClusterCommand fc = ClusterCommands.SingleOrDefault(f => f.ClusterName == cl.Name && f.Name == cmd.Name && f.Direction == Direction.ClientToServer); if (fc != null) { fc.Id = cmd.Value.Value <byte>(); fc.Cluster = cl; cl.Requests.Add(fc); } } var rspCmds = cluster["cmdRsp"]; foreach (JProperty cmd in rspCmds) { ZclClusterCommand fc = ClusterCommands.SingleOrDefault(f => f.ClusterName == cl.Name && f.Name == cmd.Name && f.Direction == Direction.ServerToClient); if (fc != null) { fc.Id = cmd.Value.Value <byte>(); fc.Cluster = cl; cl.Responses.Add(fc); } } _clusters.Add(cl); } }
List <JToken> request() //запрос на получение информации о валюте { HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync(url).Result; while (response.StatusCode != System.Net.HttpStatusCode.OK) { response = httpClient.GetAsync(url).Result; Thread.Sleep(50); } var content = response.Content.ReadAsStringAsync(); JObject jObject = JObject.Parse(content.Result); var values = jObject.Values().ToList(); while (date.Date < values[0].ToObject <DateTime>().Date) { response = httpClient.GetAsync("https:" + values[2].ToString()).Result; while (response.StatusCode != System.Net.HttpStatusCode.OK) { var url2 = "https://www.cbr-xml-daily.ru/archive/" + values[0].ToObject <DateTime>().Year + "/" + values[0].ToObject <DateTime>().Month + "/" + values[0].ToObject <DateTime>().Day + "/daily_json.js"; response = httpClient.GetAsync(new Uri(url2)).Result; values[0] = values[0].ToObject <DateTime>().AddDays(-1); Thread.Sleep(50); } Thread.Sleep(50); content = response.Content.ReadAsStringAsync(); jObject = JObject.Parse(content.Result); values = jObject.Values().ToList(); } var str = jObject.SelectToken(@"$.Valute").Values(); return(str.ToList <JToken>()); }
public static List <JObject> jObjectToList(string name, JObject inJObject) { JObject outJObject = (JObject)inJObject[name]; List <JObject> outList = new List <JObject>(); foreach (var item in outJObject.Values()) { outList.Add((JObject)item); } return(outList); }
public jDataRow(JObject obj) { foreach (Newtonsoft.Json.Linq.JToken con in obj.Values()) { if (con is JProperty) { JProperty c = con as JProperty; this.Add(c.Name, c.Value); } } }
public void Ordering() { JObject o = new JObject( new JProperty("Integer", new JValue(1)), new JProperty("Float", new JValue(1.2d)), new JProperty("Decimal", new JValue(1.1m)) ); IList<object> orderedValues = o.Values().Cast<JValue>().OrderBy(v => v).Select(v => v.Value).ToList(); Assert.AreEqual(1, orderedValues[0]); Assert.AreEqual(1.1, orderedValues[1]); Assert.AreEqual(1.2, orderedValues[2]); }