good morning!!!!

Skip to content
Snippets Groups Projects
Commit b65f29f8 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Added JavaScript JSON helper

parent 65a802c6
No related branches found
No related tags found
No related merge requests found
package ethutil
import "reflect"
import (
"encoding/json"
"reflect"
)
// The list type is an anonymous slice handler which can be used
// for containing any slice type to use in an environment which
......@@ -44,3 +47,15 @@ func (self *List) Append(v interface{}) {
func (self *List) Interface() interface{} {
return self.list.Interface()
}
// For JavaScript <3
func (self *List) ToJSON() string {
var list []interface{}
for i := 0; i < self.Length; i++ {
list = append(list, self.Get(i))
}
data, _ := json.Marshal(list)
return string(data)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment