MCPcopy
hub / github.com/perkeep/perkeep / mapJSON

Function mapJSON

pkg/schema/schema.go:675–690  ·  view source on GitHub ↗

JSON returns the map m encoded as JSON in its recommended canonical form. The canonical form is readable with newlines and indentation, and always starts with the header bytes: {"camliVersion":

(m map[string]interface{})

Source from the content-addressed store, hash-verified

673//
674// {"camliVersion":
675func mapJSON(m map[string]interface{}) (string, error) {
676 version, hasVersion := m["camliVersion"]
677 if !hasVersion {
678 return "", ErrNoCamliVersion
679 }
680 delete(m, "camliVersion")
681 jsonBytes, err := json.MarshalIndent(m, "", " ")
682 if err != nil {
683 return "", err
684 }
685 m["camliVersion"] = version
686 var buf bytes.Buffer
687 fmt.Fprintf(&buf, "{\"camliVersion\": %v,\n", version)
688 buf.Write(jsonBytes[2:])
689 return buf.String(), nil
690}
691
692// NewFileMap returns a new builder of a type "file" schema for the provided fileName.
693// The chunk parts of the file are not populated.

Callers 2

BlobMethod · 0.85
JSONMethod · 0.85

Calls 3

deleteFunction · 0.85
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected