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{})
| 673 | // |
| 674 | // {"camliVersion": |
| 675 | func 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. |