<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/json_array/write.go
diff options
context:
space:
mode:
Diffstat (limited to 'json_array/write.go')
-rw-r--r--json_array/write.go27
1 files changed, 11 insertions, 16 deletions
diff --git a/json_array/write.go b/json_array/write.go
index 4d202c4..aaa2851 100644
--- a/json_array/write.go
+++ b/json_array/write.go
@@ -7,7 +7,7 @@ import (
"encoding/json"
)
-func assembleValue(atoms []walk.Atom) (interface{}, []walk.Atom) {
+func assembleValue(atoms []walk.AtomOLD) (interface{}, []walk.AtomOLD) {
if len(atoms) == 0 {
panic("Missing JSON value in output")
}
@@ -89,21 +89,16 @@ func assembleValue(atoms []walk.Atom) (interface{}, []walk.Atom) {
}
}
-func outputValue(atoms []walk.Atom, writer *bufio.Writer) {
- if len(atoms) == 0 {
- return
- }
- value, atoms := assembleValue(atoms)
- if len(atoms) != 0 {
- panic("Tried to output more than one JSON value")
- }
- bytes, err := json.MarshalIndent(value, "\t", "\t")
- if err != nil {
- panic("Error marshalling json into bytes")
- }
- _, err = writer.Write(bytes)
- if err != nil {
- panic("Error writing value")
+func outputValue(values []interface{}, writer *bufio.Writer) {
+ for _, value := range values {
+ bytes, err := json.MarshalIndent(value, "\t", "\t")
+ if err != nil {
+ panic("Error marshalling json into bytes")
+ }
+ _, err = writer.Write(bytes)
+ if err != nil {
+ panic("Error writing value")
+ }
}
}