Permalink
Browse files

got rid of the shitty json

  • Loading branch information...
1 parent 3a92e00 commit c1a13916c44fd6a55d1d57162940c886493ea7a0 @agonopol agonopol committed Sep 17, 2011
Showing with 6 additions and 10 deletions.
  1. +0 −2 cell.go
  2. +6 −8 world.go
View
@@ -1,8 +1,6 @@
package strugglin
import "math"
-// import "fmt"
-
type CellState struct {
View
@@ -1,10 +1,7 @@
package strugglin
import "rand"
-import "drw/json"
-import "bytes"
-import "os"
-
+import "json"
type World struct {
origin*Cell
@@ -20,13 +17,14 @@ func (this * World) ToJson() string {
object["players"] = make([]interface{}, len(this.Players))
i := 0
for _,player := range this.Players {
- json.Dumps(player.Serialize(), os.Stdout)
object["players"].([]interface{})[i] = player.Serialize()
i++
}
- buffer := bytes.NewBufferString("")
- json.Dumps(object,buffer)
- return buffer.String()
+ marshaled, err := json.Marshal(object)
+ if err!=nil {
+ panic(err)
+ }
+ return string(marshaled)
}

0 comments on commit c1a1391

Please sign in to comment.