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

Method UpdateObjectAsJSON

stack.go:248–255  ·  view source on GitHub ↗

UpdateObjectAsJSON is a helper function for Update 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.

(id uint64, newValue interface{})

Source from the content-addressed store, hash-verified

246//
247// Use this function to handle encoding of complex types.
248func (s *Stack) UpdateObjectAsJSON(id uint64, newValue interface{}) (*Item, error) {
249 jsonBytes, err := json.Marshal(newValue)
250 if err != nil {
251 return nil, err
252 }
253
254 return s.Update(id, jsonBytes)
255}
256
257// Length returns the total number of items in the stack.
258func (s *Stack) Length() uint64 {

Calls 1

UpdateMethod · 0.95