Created
November 6, 2018 11:02
-
-
Save sugab/2c7cf19ecad3e761b802fe6ab313a59b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"io/ioutil" | |
) | |
func readJSON(fileName string, filter func(map[string]interface{}) bool) []map[string]interface{} { | |
datas := []map[string]interface{}{} | |
file, _ := ioutil.ReadFile(fileName) | |
json.Unmarshal(file, &datas) | |
filteredData := []map[string]interface{}{} | |
for _, data := range datas { | |
// Do some filtering | |
if filter(data) { | |
filteredData = append(filteredData, data) | |
} | |
} | |
return filteredData | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment