mirror of
https://github.com/go-i2p/go-i2pcontrol.git
synced 2025-07-13 10:07:12 -04:00
I at least need this much to start.
This commit is contained in:
37
json.go
Normal file
37
json.go
Normal file
@ -0,0 +1,37 @@
|
||||
package i2pcontrol
|
||||
|
||||
type jsonStructure struct {
|
||||
echo string
|
||||
}
|
||||
|
||||
func (j *jsonStructure) Id() string {
|
||||
rstring := randomString(10)
|
||||
return rstring
|
||||
}
|
||||
|
||||
func (j *jsonStructure) Format(m string, s []string) string {
|
||||
rstring := "{\n"
|
||||
rstring += "method: \"" + m +"\"\n"
|
||||
rstring += "jsonrpc: \"2.0\"\n"
|
||||
rstring += "id: \"" + j.Id() + "\"\n"
|
||||
rstring += "params: \""
|
||||
for _, value := range s {
|
||||
rstring += value + " "
|
||||
}
|
||||
rstring += "\"\n"
|
||||
rstring += "}\n"
|
||||
return rstring
|
||||
}
|
||||
|
||||
func (j *jsonStructure) Echo(s ...string) string{
|
||||
return j.Format("echo", s)
|
||||
}
|
||||
|
||||
func (j *jsonStructure) jsonStructure() jsonStructure {
|
||||
return *j
|
||||
}
|
||||
|
||||
func newJsonStructure() *jsonStructure {
|
||||
var j jsonStructure
|
||||
return &j
|
||||
}
|
Reference in New Issue
Block a user