本文整理汇总了C#中JsonObject.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetValue方法的具体用法?C# JsonObject.GetValue怎么用?C# JsonObject.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetString
public void GetString()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1.text);
// test direct query
Assert.That ( json.IsString ("name1") );
Assert.That ( json.GetString ("name1").Equals(value1) );
JsonValue jv = json.GetValue("name1");
Assert.That ( jv.isString );
Assert.That ( jv.stringValue.Equals(value1) );
}
示例2: IsNotOtherThanString
public void IsNotOtherThanString()
{
JsonObject json = new JsonObject();
json.ParseDocument(testInput1);
// test direct query
Assert.That ( !json.IsArray ("name1") );
Assert.That ( !json.IsBool ("name1") );
Assert.That ( !json.IsDouble ("name1") );
Assert.That ( !json.IsInt ("name1") );
Assert.That ( !json.IsNull ("name1") );
Assert.That ( !json.IsNumber ("name1") );
Assert.That ( !json.IsObject ("name1") );
JsonValue jv = json.GetValue("name1");
Assert.That ( !jv.isArray );
Assert.That ( !jv.isBool );
Assert.That ( !jv.isDouble );
Assert.That ( !jv.isInt );
Assert.That ( !jv.isNull );
Assert.That ( !jv.isNumber );
Assert.That ( !jv.isObject );
}
示例3: BuildFromCode
public void BuildFromCode()
{
JsonObject json = new JsonObject();
json.AddMember("member1", "INIT");
json.AddMember("member2","foobar");
json.AddMember("member3");
JsonValue jv = json.GetValue ("member3");
jv.SetArray();
jv.array.PushBack(1);
jv.array.PushBack(2);
jv.array.PushBack(3);
jv.array.PushBack(4);
JsonObject jsonObj = new JsonObject();
jsonObj.AddMember("intv", 123);
jsonObj.AddMember("srtv", "hoge");
jsonObj.AddMember("doublev", 123.456);
json.AddMember("member4", jsonObj);
Debug.Log (json.ToPrettyString ());
}
示例4: CreateSessionFromPayload
private IAuthSession CreateSessionFromPayload(IRequest req, JsonObject jwtPayload)
{
var expiresAt = GetUnixTime(jwtPayload, "exp");
var secondsSinceEpoch = DateTime.UtcNow.ToUnixTime();
if (secondsSinceEpoch >= expiresAt)
throw new TokenException(ErrorMessages.TokenExpired);
if (InvalidateTokensIssuedBefore != null)
{
var issuedAt = GetUnixTime(jwtPayload, "iat");
if (issuedAt == null || issuedAt < InvalidateTokensIssuedBefore.Value.ToUnixTime())
throw new TokenException(ErrorMessages.TokenInvalidated);
}
string audience;
if (jwtPayload.TryGetValue("aud", out audience))
{
if (audience != Audience)
throw new TokenException("Invalid Audience: " + audience);
}
var sessionId = jwtPayload.GetValue("jid", SessionExtensions.CreateRandomSessionId);
var session = SessionFeature.CreateNewSession(req, sessionId);
session.PopulateFromMap(jwtPayload);
PopulateSessionFilter?.Invoke(session, jwtPayload, req);
HostContext.AppHost.OnSessionFilter(session, sessionId);
return session;
}