MCPcopy Create free account
hub / github.com/devploit/nomore403 / flushJSONToStdout

Function flushJSONToStdout

cmd/output.go:122–151  ·  view source on GitHub ↗

flushJSONToStdout writes JSON results to stdout when no output file is specified.

()

Source from the content-addressed store, hash-verified

120
121// flushJSONToStdout writes JSON results to stdout when no output file is specified.
122func flushJSONToStdout() {
123 if (!jsonOutput && !jsonLines) || outputWriter != nil {
124 return
125 }
126
127 jsonResultsMutex.Lock()
128 defer jsonResultsMutex.Unlock()
129
130 if len(jsonResults) == 0 {
131 return
132 }
133
134 if jsonLines {
135 for _, item := range jsonResults {
136 data, err := json.Marshal(item)
137 if err != nil {
138 fmt.Fprintf(os.Stderr, "[!] Error marshaling JSON: %v\n", err)
139 return
140 }
141 fmt.Println(string(data))
142 }
143 return
144 }
145 data, err := json.MarshalIndent(jsonResults, "", " ")
146 if err != nil {
147 fmt.Fprintf(os.Stderr, "[!] Error marshaling JSON: %v\n", err)
148 return
149 }
150 fmt.Println(string(data))
151}

Callers 1

root.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected