本文整理汇总了Golang中github.com/keybase/go-jsonw.NewArray函数的典型用法代码示例。如果您正苦于以下问题:Golang NewArray函数的具体用法?Golang NewArray怎么用?Golang NewArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewArray函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: showJSONResults
func (c *CmdSearch) showJSONResults(results []keybase1.UserSummary) error {
output := jsonw.NewArray(len(results))
for userIndex, user := range results {
userBlob := jsonw.NewDictionary()
userBlob.SetKey("username", jsonw.NewString(user.Username))
for _, social := range user.Proofs.Social {
userBlob.SetKey(social.ProofType, jsonw.NewString(social.ProofName))
}
if len(user.Proofs.Web) > 0 {
var webProofs []string
for _, webProof := range user.Proofs.Web {
for _, protocol := range webProof.Protocols {
webProofs = append(webProofs, libkb.MakeURI(protocol, webProof.Hostname))
}
}
websites := jsonw.NewArray(len(webProofs))
for i, wp := range webProofs {
websites.SetIndex(i, jsonw.NewString(wp))
}
userBlob.SetKey("websites", websites)
}
output.SetIndex(userIndex, userBlob)
}
GlobUI.Println(output.MarshalPretty())
return nil
}
开发者ID:Varjelus,项目名称:keybase-client,代码行数:28,代码来源:cmd_search.go
示例2: runJSON
func (e *ListTrackingEngine) runJSON(trackList TrackList, verbose bool) error {
var tmp []*jsonw.Wrapper
for _, link := range trackList {
var rec *jsonw.Wrapper
var e2 error
if verbose {
rec = link.GetPayloadJSON()
} else if rec, e2 = condenseRecord(link); e2 != nil {
e.G().Log.Warning("In conversion to JSON: %s", e2)
}
if e2 == nil {
tmp = append(tmp, rec)
}
}
ret := jsonw.NewArray(len(tmp))
for i, r := range tmp {
if err := ret.SetIndex(i, r); err != nil {
return err
}
}
e.jsonResult = ret.MarshalPretty()
return nil
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:25,代码来源:list_tracking.go
示例3: MarshalToJSON
func (sh SigHints) MarshalToJSON() *jsonw.Wrapper {
ret := jsonw.NewDictionary()
ret.SetKey("version", jsonw.NewInt(sh.version))
ret.SetKey("hints", jsonw.NewArray(len(sh.hints)))
i := 0
for _, v := range sh.hints {
ret.AtKey("hints").SetIndex(i, v.MarshalToJSON())
i++
}
return ret
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:11,代码来源:sig_hints.go
示例4: createKeyFamily
func createKeyFamily(bundles []string) (*KeyFamily, error) {
allKeys := jsonw.NewArray(len(bundles))
for i, bundle := range bundles {
err := allKeys.SetIndex(i, jsonw.NewString(bundle))
if err != nil {
return nil, err
}
}
publicKeys := jsonw.NewDictionary()
publicKeys.SetKey("all_bundles", allKeys)
return ParseKeyFamily(publicKeys)
}
开发者ID:mark-adams,项目名称:client,代码行数:12,代码来源:sig_chain_test.go
示例5: TrackingStatement
// TrackingStatement generates the remote proofs portions of the
// tracking statement from the active proofs.
func (r *RemoteProofLinks) TrackingStatement() *jsonw.Wrapper {
var proofs []*jsonw.Wrapper
for _, x := range r.active() {
d, err := x.link.ToTrackingStatement(x.state)
if err != nil {
G.Log.Warning("Problem with a proof: %s", err)
continue
}
if d != nil {
proofs = append(proofs, d)
}
}
res := jsonw.NewArray(len(proofs))
for i, proof := range proofs {
res.SetIndex(i, proof)
}
return res
}
开发者ID:mattcurrycom,项目名称:client,代码行数:21,代码来源:remote_proof_links.go
示例6: RevokeSigsProof
func (u *User) RevokeSigsProof(key GenericKey, sigIDsToRevoke []keybase1.SigID) (*jsonw.Wrapper, error) {
ret, err := ProofMetadata{
Me: u,
LinkType: RevokeType,
SigningKey: key,
}.ToJSON(u.G())
if err != nil {
return nil, err
}
body := ret.AtKey("body")
revokeSection := jsonw.NewDictionary()
idsArray := jsonw.NewArray(len(sigIDsToRevoke))
for i, id := range sigIDsToRevoke {
idsArray.SetIndex(i, jsonw.NewString(id.ToString(true)))
}
revokeSection.SetKey("sig_ids", idsArray)
body.SetKey("revoke", revokeSection)
return ret, nil
}
开发者ID:polluks,项目名称:client,代码行数:19,代码来源:kbsig.go
示例7: ToTrackingStatementPGPKeys
func (u *User) ToTrackingStatementPGPKeys(errp *error) *jsonw.Wrapper {
keys := u.GetActivePGPKeys(true)
if len(keys) == 0 {
return nil
}
ret := jsonw.NewArray(len(keys))
for i, k := range keys {
kd := jsonw.NewDictionary()
kid := k.GetKID()
fp := k.GetFingerprintP()
kd.SetKey("kid", jsonw.NewString(kid.String()))
if fp != nil {
kd.SetKey("key_fingerprint", jsonw.NewString(fp.String()))
}
ret.SetIndex(i, kd)
}
return ret
}
开发者ID:polluks,项目名称:client,代码行数:19,代码来源:kbsig.go
注:本文中的github.com/keybase/go-jsonw.NewArray函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论