MCPcopy Create free account
hub / github.com/beeker1121/goque / PushObjectAsJSON

Method PushObjectAsJSON

stack.go:114–121  ·  view source on GitHub ↗

PushObjectAsJSON is a helper function for Push that accepts any value type, which is then encoded into a JSON byte slice using encoding/json. Use this function to handle encoding of complex types.

(value interface{})

Source from the content-addressed store, hash-verified

112//
113// Use this function to handle encoding of complex types.
114func (s *Stack) PushObjectAsJSON(value interface{}) (*Item, error) {
115 jsonBytes, err := json.Marshal(value)
116 if err != nil {
117 return nil, err
118 }
119
120 return s.Push(jsonBytes)
121}
122
123// Pop removes the next item in the stack and returns it.
124func (s *Stack) Pop() (*Item, error) {

Callers 2

Calls 1

PushMethod · 0.95

Tested by 2