本文整理汇总了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");
}
示例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();
}
示例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);
}
}
示例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();
}
示例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"));
}
示例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))
};
}
示例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;
}
示例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);
}
示例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()
)
};
}
示例10: ExtractMetadata
public override CldrJsonMetadata ExtractMetadata(JObject obj)
{
return new CldrJsonMetadata
{
CldrVersion = obj.SelectToken("supplemental.version._cldrVersion").ToString()
};
}
示例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;
}
}
示例12: EvaluateEmptyStringWithMatchingEmptyProperty
public void EvaluateEmptyStringWithMatchingEmptyProperty()
{
JObject o = new JObject(
new JProperty(" ", 1));
JToken t = o.SelectToken("[' ']");
Assert.AreEqual(1, (int)t);
}
示例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;
}
示例14: EvaluateEmptyPropertyIndexer
public void EvaluateEmptyPropertyIndexer()
{
JObject o = new JObject(
new JProperty("", 1));
JToken t = o.SelectToken("['']");
Assert.AreEqual(1, (int)t);
}
示例15: EvaluateDollarString
public void EvaluateDollarString()
{
JObject o = new JObject(
new JProperty("Blah", 1));
JToken t = o.SelectToken("$");
Assert.AreEqual(o, t);
}