MCPcopy
hub / github.com/wavetermdev/waveterm / ParseIJson

Function ParseIJson

pkg/ijson/ijson.go:655–675  ·  view source on GitHub ↗

returns a list of commands

(fullData []byte)

Source from the content-addressed store, hash-verified

653
654// returns a list of commands
655func ParseIJson(fullData []byte) ([]Command, error) {
656 var commands []Command
657 for len(fullData) > 0 {
658 nlIdx := bytes.IndexByte(fullData, '\n')
659 var cmdData []byte
660 if nlIdx == -1 {
661 cmdData = fullData
662 fullData = nil
663 } else {
664 cmdData = fullData[:nlIdx]
665 fullData = fullData[nlIdx+1:]
666 }
667 var cmdMap Command
668 err := json.Unmarshal(cmdData, &cmdMap)
669 if err != nil {
670 return nil, fmt.Errorf("error unmarshalling ijson command: %w", err)
671 }
672 commands = append(commands, cmdMap)
673 }
674 return commands, nil
675}

Callers 1

TestIJsonFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestIJsonFunction · 0.74