Documentation ¶
Index ¶
- func AssertJson(data []byte, paramName string) error
- func AssertJsonString(jsonStr string, paramName string) error
- func GetLibrary() string
- func IsJson(data []byte) bool
- func IsJsonString(str string) bool
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalIndentToString(v interface{}, prefix, indent string) (string, error)
- func MarshalIndentToStringWithAPI(api API, v interface{}, prefix, indent string) (string, error)
- func MarshalIndentWithAPI(api API, v interface{}, prefix, indent string) ([]byte, error)
- func MarshalToFile(in interface{}, filePath string, perm os.FileMode) error
- func MarshalToFileWithAPI(api API, in interface{}, filePath string, perm os.FileMode) error
- func MarshalToString(v interface{}) (string, error)
- func MarshalToStringWithAPI(api API, v interface{}) (string, error)
- func MarshalWithAPI(api API, v interface{}) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalFromString(str string, v interface{}) error
- func UnmarshalFromStringWithAPI(api API, str string, v interface{}) error
- func UnmarshalWithAPI(api API, data []byte, v interface{}) error
- type API
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertJson ¶ added in v3.0.86
func AssertJsonString ¶ added in v3.0.86
func GetLibrary ¶
func GetLibrary() string
func IsJsonString ¶ added in v3.0.83
func MarshalIndentToStringWithAPI ¶
MarshalIndentToStringWithAPI
@param indent 为了兼容性,用" "(4个空格)替代"\t"
func MarshalToFile ¶
MarshalToFile
PS: (1) 对 传参filePath 的验证和断言在 fileKit.WriteToFile 里面; (2) 写入文件的json带有 indent.
@param in 建议为结构体实例指针 || map实例 || slice实例 @param filePath (1) .json 格式的文件
(2) 不存在的话,会创建一个新的文件 (3) 存在且是个文件的话,会 "覆盖" 掉旧的(并不会加到该文件的最后面)
func MarshalToFileWithAPI ¶
MarshalToFileWithAPI
PS: (1) 对 传参filePath 的验证和断言在 fileKit.WriteToFile 里面; (2) 写入文件的json带有 indent.
@param in 建议为结构体实例指针 || map实例 || slice实例 @param filePath (1) .json 格式的文件
(2) 不存在的话,会创建一个新的文件 (3) 存在且是个文件的话,会 "覆盖" 掉旧的(并不会加到该文件的最后面)
func MarshalToStringWithAPI ¶
func MarshalWithAPI ¶
func Unmarshal ¶
Unmarshal 反序列化
@param v (1) 必须是指针(结构体实例指针 || map实例指针 || slice实例指针);
(2) 如果为 slice 或 map 类型,值可以为nil.
func UnmarshalFromString ¶
func UnmarshalWithAPI ¶
Types ¶
type API ¶
type API interface { Marshal(v interface{}) ([]byte, error) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) MarshalToString(v interface{}) (string, error) Unmarshal(data []byte, v interface{}) error UnmarshalFromString(str string, v interface{}) error }
func GetDefaultApi ¶
func GetDefaultApi() API
Click to show internal directories.
Click to hide internal directories.