sjson_write支持删除数据
This commit is contained in:
parent
c7ce590e3b
commit
691bee91a5
@ -11,6 +11,8 @@ package abstract
|
|||||||
type IJsonWrite interface {
|
type IJsonWrite interface {
|
||||||
// Set 设置一个路径的值
|
// Set 设置一个路径的值
|
||||||
Set(dataPath string, data any) error
|
Set(dataPath string, data any) error
|
||||||
|
// Delete 删除一个路径
|
||||||
|
Delete(dataPath string) error
|
||||||
// Result 最终结果以字符串形式返回
|
// Result 最终结果以字符串形式返回
|
||||||
Result() string
|
Result() string
|
||||||
// Map 最终结果以map返回
|
// Map 最终结果以map返回
|
||||||
|
@ -28,6 +28,16 @@ type SjsonWrite struct {
|
|||||||
l *sync.RWMutex
|
l *sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SjsonWrite) Delete(dataPath string) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if s.res, err = sjson.Delete(s.res, dataPath); nil != err {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SjsonWrite) Set(dataPath string, data any) error {
|
func (s *SjsonWrite) Set(dataPath string, data any) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user