本文整理汇总了Golang中github.com/pomack/jsonhelper/go/jsonhelper.JSONObject类的典型用法代码示例。如果您正苦于以下问题:Golang JSONObject类的具体用法?Golang JSONObject怎么用?Golang JSONObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSONObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetFromJSON
func (p *loginAccountContext) SetFromJSON(obj jsonhelper.JSONObject) {
p.username = obj.GetAsString("username")
p.password = obj.GetAsString("password")
p.inputValidated = false
p.user = nil
p.result = nil
}
示例2: SetFromJSON
func (p *updateContactContext) SetFromJSON(obj jsonhelper.JSONObject) {
contact := new(dm.Contact)
if obj == nil {
contact = nil
} else {
json.Unmarshal([]byte(obj.String()), contact)
}
p.contact = contact
}
示例3: FromJSON
func (p *Name) FromJSON(o jsonhelper.JSONObject) {
p.GivenName = o.GetAsString("givenName")
p.MiddleName = o.GetAsString("middleName")
p.FamilyName = o.GetAsString("familyName")
p.Prefix = o.GetAsString("prefix")
p.Suffix = o.GetAsString("suffix")
p.GivenNameSound = o.GetAsString("givenNameSound")
p.FamilyNameSound = o.GetAsString("familyNameSound")
}
示例4: HandleInputHandlerAfterSetup
func (p *SetPasswordRequestHandler) HandleInputHandlerAfterSetup(cxt SetPasswordContext) (int, http.Header, io.WriterTo) {
errors := make(map[string][]error)
var obj jsonhelper.JSONObject
var err error
authDS := p.authDS
if user := cxt.User(); user != nil {
var userPassword *dm.UserPassword
if user != nil {
userPassword = dm.NewUserPassword(user.Id, cxt.Password())
} else {
userPassword = dm.NewUserPassword("", cxt.Password())
}
userPassword.Validate(true, errors)
if len(errors) == 0 {
userPassword, err = authDS.StoreUserPassword(userPassword)
}
obj = jsonhelper.NewJSONObject()
userObj, _ := jsonhelper.Marshal(user)
obj.Set("user", userObj)
obj.Set("type", "user")
obj.Set("message", "password changed")
} else {
return apiutil.OutputErrorMessage(ERR_MUST_SPECIFY_USERNAME.Error(), time.Time{}, http.StatusBadRequest, nil)
}
if len(errors) > 0 {
return apiutil.OutputErrorMessage("Value errors. See result", errors, http.StatusBadRequest, nil)
}
if err != nil {
return apiutil.OutputErrorMessage(err.Error(), time.Time{}, http.StatusInternalServerError, nil)
}
cxt.SetResult(obj)
return 0, nil, nil
}
示例5: SetFromJSON
func (p *createAccountContext) SetFromJSON(obj jsonhelper.JSONObject) {
p.user = nil
p.consumer = nil
p.externalUser = nil
theType := p.theType
if theType == "" {
theType = obj.GetAsString("type")
}
switch theType {
case "user":
p.user = new(dm.User)
p.user.InitFromJSONObject(obj)
case "consumer":
p.consumer = new(dm.Consumer)
p.consumer.InitFromJSONObject(obj)
case "external_user":
p.externalUser = new(dm.ExternalUser)
p.externalUser.InitFromJSONObject(obj)
}
}
示例6: FromJSON
func (p *googleUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
p.id = props.GetAsObject("id").GetAsString("$t")
authorArr := props.GetAsArray("author")
if len(authorArr) > 0 {
author := jsonhelper.JSONValueToObject(authorArr[0])
p.name = author.GetAsObject("name").GetAsString("$t")
p.email = author.GetAsObject("email").GetAsString("$t")
}
for _, l := range props.GetAsArray("link") {
m := jsonhelper.JSONValueToObject(l)
if m.GetAsString("rel") == _GOOGLE_USERINFO_FEED_REL {
p.uri = m.GetAsString("href")
}
}
p.updated = props.GetAsObject("updated").GetAsTime("$t", GOOGLE_DATETIME_FORMAT)
}
示例7: InitFromJSONObject
func (p *ExternalUser) InitFromJSONObject(obj jsonhelper.JSONObject) {
p.PersistableModel.InitFromJSONObject(obj)
p.ConsumerId = obj.GetAsString("consumer_id")
p.ExternalUserId = obj.GetAsString("external_user_id")
p.Name = obj.GetAsString("name")
}
示例8: FromJSON
func (p *facebookLocation) FromJSON(props jsonhelper.JSONObject) {
p.id = props.GetAsString("id")
p.name = props.GetAsString("name")
}
示例9: Initialize
func (p *linkedInClient) Initialize(properties jsonhelper.JSONObject) {
if p.currentCredentials == nil {
p.currentCredentials = NewStandardAuthToken()
}
if properties == nil {
return
}
if v := properties.GetAsString("linkedin.api.key"); len(v) > 0 {
p.consumerKey = v
//p.Credentials.Token = v
}
if v := properties.GetAsString("linkedin.client.redirect_uri"); len(v) > 0 {
p.callbackUrl = v
}
if v := properties.GetAsString("linkedin.secret.key"); len(v) > 0 {
p.consumerSecret = v
//p.Credentials.Secret = v
}
if v := properties.GetAsString("linkedin.oauth1.scope"); len(v) > 0 {
//p.Scope = v
}
if v := properties.GetAsString("linkedin.client.token"); len(v) > 0 {
p.currentCredentials.SetToken(v)
}
if v := properties.GetAsString("linkedin.client.secret"); len(v) > 0 {
p.currentCredentials.SetSecret(v)
}
}
示例10: SetFromJSON
func (p *setPasswordContext) SetFromJSON(obj jsonhelper.JSONObject) {
p.password = obj.GetAsString("password")
p.result = nil
}
示例11: FromJSON
func (p *yahooUserInfoIm) FromJSON(props jsonhelper.JSONObject) {
p.handle = props.GetAsString("handle")
p.id = props.GetAsInt("id")
p.theType = props.GetAsString("type")
}
示例12: Initialize
func (p *yahooClient) Initialize(properties jsonhelper.JSONObject) {
if p.currentCredentials == nil {
p.currentCredentials = &yahooAccessTokenResult{}
}
if properties == nil {
return
}
if v := properties.GetAsString("yahoo.realm"); len(v) > 0 {
p.realm = v
}
if v := properties.GetAsString("yahoo.consumer.key"); len(v) > 0 {
p.consumerKey = v
//p.Credentials.Token = v
}
if v := properties.GetAsString("yahoo.consumer.secret"); len(v) > 0 {
p.consumerSecret = v
//p.Credentials.Secret = v
}
if v := properties.GetAsString("yahoo.client.redirect_uri"); len(v) > 0 {
p.callbackUrl = v
}
if v := properties.GetAsString("yahoo.oauth1.scope"); len(v) > 0 {
//p.Scope = v
}
if v := properties.GetAsString("yahoo.client.token"); len(v) > 0 {
p.currentCredentials.SetToken(v)
}
if v := properties.GetAsString("yahoo.client.secret"); len(v) > 0 {
p.currentCredentials.SetSecret(v)
}
}
示例13: FromJSON
func (p *smugMugUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
LogDebug("user info result from json: ", props)
p.id = props.GetAsInt64("id")
p.accountStatus = props.GetAsString("AccountStatus")
p.accountType = props.GetAsString("AccountType")
p.fileSizeLimit = props.GetAsInt64("FileSizeLimit")
p.name = props.GetAsString("Name")
p.nickname = props.GetAsString("NickName")
p.smugVault = props.GetAsBool("SmugVault")
p.url = props.GetAsString("URL")
}
示例14: Initialize
func (p *smugMugClient) Initialize(properties jsonhelper.JSONObject) {
if p.currentCredentials == nil {
p.currentCredentials = NewStandardAuthToken()
}
if properties == nil {
return
}
if v := properties.GetAsString("smugmug.realm"); len(v) > 0 {
p.realm = v
}
if v := properties.GetAsString("smugmug.app.name"); len(v) > 0 {
p.appName = v
}
if v := properties.GetAsString("smugmug.consumer.key"); len(v) > 0 {
p.consumerKey = v
//p.Credentials.Token = v
}
if v := properties.GetAsString("smugmug.consumer.secret"); len(v) > 0 {
p.consumerSecret = v
//p.Credentials.Secret = v
}
if v := properties.GetAsString("smugmug.client.redirect_uri"); len(v) > 0 {
p.callbackUrl = v
}
if v := properties.GetAsString("smugmug.oauth1.scope"); len(v) > 0 {
//p.Scope = v
}
if v := properties.GetAsString("smugmug.client.token"); len(v) > 0 {
p.currentCredentials.SetToken(v)
}
if v := properties.GetAsString("smugmug.client.secret"); len(v) > 0 {
p.currentCredentials.SetSecret(v)
}
}
示例15: InitFromJSONObject
func (p *PersistableModel) InitFromJSONObject(obj jsonhelper.JSONObject) {
p.Id = obj.GetAsString("id")
p.Etag = obj.GetAsString("etag")
p.CreatedAt = obj.GetAsInt64("created_at")
p.ModifiedAt = obj.GetAsInt64("modified_at")
}