mirror of https://github.com/skanehira/tson
Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
skanehira | c6350f3337 | 3 years ago |
skanehira | 4f590aae4e | 5 years ago |
skanehira | 061f693a5f | 5 years ago |
skanehira | 669f19fe9b | 5 years ago |
skanehira | ca51ccc045 | 5 years ago |
skanehira | 41a970b963 | 5 years ago |
skanehira | b251ec1363 | 5 years ago |
skanehira | 7f3874bf16 | 5 years ago |
skanehira | 6e97b2dd7e | 5 years ago |
skanehira | d5a9b6c749 | 5 years ago |
skanehira | 18ed987be1 | 5 years ago |
skanehira | 706bb85b5c | 5 years ago |
@ -0,0 +1,28 @@
|
|||||||
|
package lib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/skanehira/tson/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Edit use tson as a library
|
||||||
|
func Edit(b []byte) ([]byte, error) {
|
||||||
|
// dont output log
|
||||||
|
log.SetOutput(ioutil.Discard)
|
||||||
|
|
||||||
|
var i interface{}
|
||||||
|
if err := json.Unmarshal(b, &i); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := gui.New()
|
||||||
|
if err := g.Run(i); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(g.MakeJSON(g.Tree.GetRoot()))
|
||||||
|
}
|
Loading…
Reference in New Issue