MarshalJSON marshals shell commands according to s.MarshalAs. It marshals commands to a string by joining s.Cmds with newlines.
()
| 80 | // MarshalJSON marshals shell commands according to s.MarshalAs. It marshals |
| 81 | // commands to a string by joining s.Cmds with newlines. |
| 82 | func (s Commands) MarshalJSON() ([]byte, error) { |
| 83 | switch s.MarshalAs { |
| 84 | case CmdArray: |
| 85 | return cuecfg.MarshalJSON(s.Cmds) |
| 86 | case CmdString: |
| 87 | return cuecfg.MarshalJSON(s.String()) |
| 88 | default: |
| 89 | panic(fmt.Sprintf("invalid command format: %s", s.MarshalAs)) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // UnmarshalJSON unmarshals shell commands from a string, an array of strings, |
| 94 | // or null. When the JSON value is a string, it unmarshals into the first index |
nothing calls this directly
no test coverage detected