Skip to content

Instantly share code, notes, and snippets.

View sugab's full-sized avatar

Bagus Cahyono sugab

View GitHub Profile
package main
import (
"testing"
)
func BenchmarkMovieRead(b *testing.B) {
for n := 0; n < b.N; n++ {
readJSON("movie.json", func(data map[string]interface{}) bool {
return data["year"].(float64) >= 2010
package main
import (
"encoding/json"
"os"
)
func readJSONToken(fileName string, filter func(map[string]interface{}) bool) []map[string]interface{} {
file, _ := os.Open(fileName)
defer file.Close()
package main
import (
"encoding/json"
"io/ioutil"
)
func readJSON(fileName string, filter func(map[string]interface{}) bool) []map[string]interface{} {
datas := []map[string]interface{}{}
@sugab
sugab / json_read.go
Last active January 27, 2024 06:42
Read JSON File form a filePath. American movies dataset can be found here: https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json. 200,000+ Jeopardy question dataset can be found here: https://www.reddit.com/r/datasets/comments/1uyd0t/200000_jeopardy_questions_in_a_json_file/.
package main
import (
"encoding/json"
"io/ioutil"
)
func readJSON(fileName string, filter func(map[string]interface{}) bool) []map[string]interface{} {
datas := []map[string]interface{}{}