2023-10-31 23:19:52 +00:00
|
|
|
package aid
|
|
|
|
|
2023-12-19 16:47:13 +00:00
|
|
|
import "github.com/goccy/go-json"
|
|
|
|
|
|
|
|
type JSON map[string]interface{}
|
|
|
|
|
|
|
|
func JSONFromBytes(input []byte) JSON {
|
|
|
|
var output JSON
|
|
|
|
json.Unmarshal(input, &output)
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *JSON) ToBytes() []byte {
|
|
|
|
json, _ := json.Marshal(j)
|
|
|
|
return json
|
2024-01-21 17:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func JSONStringify(input interface{}) string {
|
|
|
|
json, _ := json.Marshal(input)
|
|
|
|
return string(json)
|
|
|
|
}
|
|
|
|
|
|
|
|
func JSONParse(input string) interface{} {
|
|
|
|
var output interface{}
|
|
|
|
json.Unmarshal([]byte(input), &output)
|
|
|
|
return output
|
2023-12-19 16:47:13 +00:00
|
|
|
}
|