Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) MarshalJSON spells with one "l" #198

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(fix) MarshalJSON spells with one "l"
  • Loading branch information
alexandear committed Sep 4, 2023
commit 6778a79ef2a306fa46fcd3411ca1a24a713f805d
13 changes: 10 additions & 3 deletions cmd/report_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/csv"
"encoding/json"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -53,7 +54,9 @@ $ gowitness report list --csv --sort`,
}

if options.ReportJSON {
outputJSON(&data)
if err := outputJSON(&data); err != nil {
log.Fatal().Err(err).Msg("failed to output json")
}
return
}

Expand All @@ -75,12 +78,16 @@ func init() {
}

// outputJSON prints the report in JSON format
func outputJSON(d *[]storage.URL) {
func outputJSON(d *[]storage.URL) error {

for _, l := range *d {
bytes, _ := l.MarshallJSON()
bytes, err := json.Marshal(l)
if err != nil {
return err
}
fmt.Print(string(bytes))
}
return nil
}

// outputCSV prints the report in CSV format
Expand Down
4 changes: 2 additions & 2 deletions storage/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (url *URL) MarshallCSV() (res []string) {
url.Filename}
}

// MarshallJSON returns values as a slice
func (url *URL) MarshallJSON() ([]byte, error) {
// MarshalJSON returns JSON encoding of url. Implements json.Marshaler.
func (url *URL) MarshalJSON() ([]byte, error) {
var tmp struct {
URL string `json:"url"`
FinalURL string `json:"final_url"`
Expand Down