转到:过滤JSON响应

I'm trying to return a json response that is filtered by only taking the struct values if the id is > 5.

A sample base code can be found here: http://play.golang.org/p/4ORba3y7F7

How do I filter the json results?

Not sure where JSON comes into it.

I'm guessing this is what you're after: http://play.golang.org/p/sEkfcEN2DJ

package main

import "fmt"

type Ping struct {
    Content []aContent
}

type aContent struct {
    Type       string
    Id         int
    Created_at int64
}

func main() {

    f := Ping{Content: []aContent{{Type: "Hello", Id: 2}, {Type: "World", Id: 6}}}

    for i := range f.Content {
        if f.Content[i].Id > 5 {
            fmt.Println(f.Content[i])
        }
    }
}