36 lines
868 B
Go
36 lines
868 B
Go
package export
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// Render JSON output.
|
|
func (export *Export) renderJSON() (render string) {
|
|
type solution_type map[string]any
|
|
solutions := make([]solution_type, 0)
|
|
|
|
for solutionIndex, solution := range export.Controller.Solutions {
|
|
solutionMap := map[string]any{
|
|
"order": solutionIndex,
|
|
"row1": solution[0],
|
|
"row2": solution[1],
|
|
"row3": solution[2],
|
|
"row4": solution[3],
|
|
"row5": solution[4],
|
|
"row6": solution[5],
|
|
"row7": solution[6],
|
|
"row8": solution[7],
|
|
"row9": solution[8],
|
|
}
|
|
solutions = append(solutions, solutionMap)
|
|
}
|
|
renderBytes, err := json.Marshal(solutions)
|
|
if err != nil {
|
|
export.Controller.Outputter.Println("ERROR: json.Marshal error:", err)
|
|
export.Controller.Outputter.Println("Printing solution as-is:", solutions)
|
|
return ""
|
|
}
|
|
render = string(renderBytes)
|
|
return
|
|
}
|