MCPcopy Create free account
hub / github.com/devld/go-drive / EncodeJSONValue

Method EncodeJSONValue

script/runtime.go:115–124  ·  view source on GitHub ↗
(value *Value)

Source from the content-addressed store, hash-verified

113}
114
115func (v *VM) EncodeJSONValue(value *Value) ([]byte, error) {
116 encoded, e := v.o.Call("JSON.stringify", nil, value.v)
117 if e != nil {
118 return nil, e
119 }
120 if encoded.IsUndefined() {
121 return nil, fmt.Errorf("value is not JSON serializable")
122 }
123 return []byte(encoded.String()), nil
124}
125
126func (v *VM) DecodeJSONValue(encoded []byte) (any, error) {
127 return v.o.Call("JSON.parse", nil, string(encoded))

Callers 1

setDataMethod · 0.80

Calls 2

StringMethod · 0.65
CallMethod · 0.45

Tested by

no test coverage detected