當前位置: 首頁>>代碼示例>>C#>>正文


C# JObject.SelectToken方法代碼示例

本文整理匯總了C#中Newtonsoft.Json.Linq.JObject.SelectToken方法的典型用法代碼示例。如果您正苦於以下問題:C# JObject.SelectToken方法的具體用法?C# JObject.SelectToken怎麽用?C# JObject.SelectToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Newtonsoft.Json.Linq.JObject的用法示例。


在下文中一共展示了JObject.SelectToken方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParsePlayer

 public void ParsePlayer(JObject playerObject)
 {
     Name = (string)playerObject.SelectToken("name");
     Stack = (int)playerObject.SelectToken("stack");
     Status = (string)playerObject.SelectToken("status");
     Bet = (int)playerObject.SelectToken("bet");
     Version = (string)playerObject.SelectToken("version");
 }
開發者ID:Sholy,項目名稱:poker-player-shoe-people,代碼行數:8,代碼來源:Player.cs

示例2: GeniAuthenticatedContext

 /// <summary>
 /// Initializes a <see cref="GeniAuthenticatedContext"/>
 /// </summary>
 /// <param name="context">The OWIN environment</param>
 /// <param name="user">The Geni user information</param>
 /// <param name="accessToken">Geni Access token</param>
 /// <param name="refreshToken">Geni Refresh token</param>
 public GeniAuthenticatedContext(IOwinContext context, JObject user, string accessToken, string refreshToken)
     : base(context)
 {
     AccessToken = accessToken;
     RefreshToken = refreshToken;
     User = user;
     Name = user.SelectToken("name").ToString();
     Id = user.SelectToken("translator_id").ToString();
 }
開發者ID:davetimmins,項目名稱:OwinOAuthProviders,代碼行數:16,代碼來源:GeniAuthenticatedContext.cs

示例3: ServiceEndpoint

 /// <summary>
 /// Creates a new Service Endpoint instance
 /// </summary>
 /// <param name="obj">JSON Object representing the Endpoint</param>
 internal ServiceEndpoint(JObject obj)
 {
     this._uri = (String)obj.SelectToken("url");
     JToken methods = obj.SelectToken("http-methods");
     foreach (JToken method in methods.Children())
     {
         this._methods.Add((String)method);
     }
 }
開發者ID:jbunzel,項目名稱:MvcRQ_git,代碼行數:13,代碼來源:ServiceEndpoint.cs

示例4: FitbitAuthenticatedContext

 /// <summary>
 /// Initializes a <see cref="FitbitAuthenticatedContext"/>
 /// </summary>
 /// <param name="context">The OWIN environment</param>
 /// <param name="user">The Fitbit user information</param>
 /// <param name="accessToken">Fitbit Access token</param>
 /// <param name="refreshToken">Fitbit Refresh token</param>
 public FitbitAuthenticatedContext(IOwinContext context, JObject user, string accessToken, string refreshToken)
     : base(context)
 {
     AccessToken = accessToken;
     RefreshToken = refreshToken;
     User = user;
     Name = user.SelectToken("user.displayName").ToString();
     Id = user.SelectToken("user.encodedId").ToString();
 }
開發者ID:uhavemyword,項目名稱:OwinOAuthProviders,代碼行數:16,代碼來源:FitbitAuthenticatedContext.cs

示例5: PelletService

 /// <summary>
 /// Creates a new Pellet Service instance
 /// </summary>
 /// <param name="name">Service Name</param>
 /// <param name="obj">JSON Object representing the Service</param>
 protected PelletService(String name, JObject obj)
 {
     this._name = name;
     JToken mimeTypes = obj.SelectToken("response-mimetype");
     foreach (JToken mimeType in mimeTypes.Children())
     {
         this._mimeTypes.Add((String)mimeType);
     }
     this._endpoint = new ServiceEndpoint((JObject)obj.SelectToken("endpoint"));
 }
開發者ID:jbunzel,項目名稱:MvcRQ_git,代碼行數:15,代碼來源:PelletService.cs

示例6: ParseParlamentaryGroup

 public ParlamentaryGroup ParseParlamentaryGroup(JObject jobject)
 {
     return new ParlamentaryGroup()
     {
         Acronym = jobject.SelectToken(c_acronym).ValueOrDefault<string>(),
         CongressUrl = jobject.SelectToken(c_congressUrl).ValueOrDefault<string>(),
         Id = jobject.SelectToken(c_id).ValueOrDefault<int>()  ,
         ParlamentaryMembers = ParseParlamentaryMembers((JArray)jobject.SelectToken(c_members))          
     };
 }
開發者ID:jmmortega,項目名稱:PicaFlor,代碼行數:10,代碼來源:PicaFlorJsonHelper.cs

示例7: DeserializeWrapper

        /// <summary>
        /// This method is copied out of the TwitterUserCollection class.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        internal static TwitterUserCollection DeserializeWrapper(JObject value)
        {
            if (value == null || value.SelectToken("users") == null)
                return null;

            TwitterUserCollection result = JsonConvert.DeserializeObject<TwitterUserCollection>(value.SelectToken("users").ToString());
            //result.NextCursor = value.SelectToken("next_cursor").Value<long>();
            //result.PreviousCursor = value.SelectToken("previous_cursor").Value<long>();

            return result;
        }
開發者ID:JohnSmithJS,項目名稱:Twitterizer,代碼行數:16,代碼來源:Issue120.cs

示例8: EvaluateEmptyString

        public void EvaluateEmptyString()
        {
            JObject o = new JObject(
                new JProperty("Blah", 1));

            JToken t = o.SelectToken("");
            Assert.AreEqual(o, t);

            t = o.SelectToken("['']");
            Assert.AreEqual(null, t);
        }
開發者ID:GhostitosHunter,項目名稱:Newtonsoft.Json,代碼行數:11,代碼來源:JPathExecuteTests.cs

示例9: ExtractMetadata

 public override CldrJsonMetadata ExtractMetadata(JObject obj)
 {
     return new CldrJsonMetadata
     {
         CldrVersion = obj.SelectToken("segments.identity.version._cldrVersion").ToString(),
         CldrLocale = new CldrLocale(
             language: obj.SelectToken("segments.identity.language").ToString(),
             script: obj.SelectToken("segments.identity.script")?.ToString(),
             territory: obj.SelectToken("segments.identity.territory")?.ToString(),
             variant: obj.SelectToken("segments.identity.variant")?.ToString()
         )
     };
 }
開發者ID:pgolebiowski,項目名稱:onism-cldr,代碼行數:13,代碼來源:SegmentsParser.cs

示例10: ExtractMetadata

 public override CldrJsonMetadata ExtractMetadata(JObject obj)
 {
     return new CldrJsonMetadata
     {
         CldrVersion = obj.SelectToken("supplemental.version._cldrVersion").ToString()
     };
 }
開發者ID:pgolebiowski,項目名稱:onism-cldr,代碼行數:7,代碼來源:SupplementalParser.cs

示例11: ApigeeResponse

 public ApigeeResponse(JObject rawData, string wantedKey) {
     RawResponse = rawData.ToString();
     try
     {
         this.ResponseData = rawData.SelectToken(wantedKey, true);
         this.success = true;
     }
     catch (Exception)
     {
         var errorMsg = rawData.SelectToken("error_description").ToString();
         if (String.IsNullOrEmpty(errorMsg))
             errorMsg = "Unknown Error";
         
         this.Error = new ApigeeResponseError(errorMsg);
         this.success = false;
     }
 }
開發者ID:zaxy78,項目名稱:Apigee.Net,代碼行數:17,代碼來源:ApigeeResponse.cs

示例12: EvaluateEmptyStringWithMatchingEmptyProperty

        public void EvaluateEmptyStringWithMatchingEmptyProperty()
        {
            JObject o = new JObject(
                new JProperty(" ", 1));

            JToken t = o.SelectToken("[' ']");
            Assert.AreEqual(1, (int)t);
        }
開發者ID:GhostitosHunter,項目名稱:Newtonsoft.Json,代碼行數:8,代碼來源:JPathExecuteTests.cs

示例13: GetText

 public static string GetText(JObject obj, string path)
 {
     string id = null;
       var idEl = obj.SelectToken(path, false);
       if (idEl != null)
     id = idEl.Value<string>();
       return id;
 }
開發者ID:Q42,項目名稱:MWHackathon,代碼行數:8,代碼來源:JSONService.cs

示例14: EvaluateEmptyPropertyIndexer

        public void EvaluateEmptyPropertyIndexer()
        {
            JObject o = new JObject(
                new JProperty("", 1));

            JToken t = o.SelectToken("['']");
            Assert.AreEqual(1, (int)t);
        }
開發者ID:andersonb,項目名稱:Newtonsoft.Json,代碼行數:8,代碼來源:JPathExecuteTests.cs

示例15: EvaluateDollarString

        public void EvaluateDollarString()
        {
            JObject o = new JObject(
                new JProperty("Blah", 1));

            JToken t = o.SelectToken("$");
            Assert.AreEqual(o, t);
        }
開發者ID:sitty,項目名稱:Newtonsoft.Json,代碼行數:8,代碼來源:JPathExecuteTests.cs


注:本文中的Newtonsoft.Json.Linq.JObject.SelectToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。