本文整理匯總了Golang中github.com/FactomProject/factomd/common/primitives.EncodeJSON函數的典型用法代碼示例。如果您正苦於以下問題:Golang EncodeJSON函數的具體用法?Golang EncodeJSON怎麽用?Golang EncodeJSON使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EncodeJSON函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExportDatabaseJSON
func ExportDatabaseJSON(db interfaces.IDatabase, convertNames bool) error {
fmt.Printf("Exporting the database\n")
if db == nil {
return nil
}
buckets, err := db.ListAllBuckets()
if err != nil {
return err
}
answer := map[string]interface{}{}
for _, bucket := range buckets {
m := map[string]interface{}{}
data, keys, err := db.GetAll(bucket, new(primitives.ByteSlice))
if err != nil {
return err
}
for i, key := range keys {
m[fmt.Sprintf("%x", key)] = data[i]
}
if convertNames == true {
answer[KeyToName(bucket)] = m
} else {
answer[fmt.Sprintf("%x", bucket)] = m
}
}
data, err := primitives.EncodeJSON(answer)
if err != nil {
return err
}
var out bytes.Buffer
json.Indent(&out, data, "", "\t")
data = out.Next(out.Len())
/*
dir := be.DataStorePath
if dir != "" {
if FileNotExists(dir) {
err := os.MkdirAll(dir, 0777)
if err == nil {
fmt.Println("Created directory " + dir)
} else {
return err
}
}
}
if dir != "" {
dir = dir + "/db.txt"
} else {
dir = "db.txt"
}*/
dir := "db.txt"
err = ioutil.WriteFile(dir, data, 0777)
if err != nil {
return err
}
return nil
}
示例2: JSONByte
func (e *MissingMsg) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例3: JSONByte
func (e *AddFederatedServer) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例4: JSONByte
func (e *Bounce) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例5: JSONByte
func (e *EntryBlockResponse) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例6: JSONByte
func (e *MsgRevealChain) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例7: JSONByte
func (e *SignatureBlock) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例8: JSONByte
func (e *AdminBlock) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例9: JSONByte
func (e *FEREntry) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例10: JSONByte
func (e *DataResponse) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例11: JSONByte
func (e *RequestBlock) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例12: JSONByte
func (e *DBStateMissing) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例13: JSONByte
func (e *MsgGetEntryData) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例14: JSONByte
func (e ByteStore) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(e)
}
示例15: JSONByte
func (s *FactoidSignature) JSONByte() ([]byte, error) {
return primitives.EncodeJSON(s)
}