-
-
Save thedevsaddam/19d9a3015838638aed77ab423003bac1 to your computer and use it in GitHub Desktop.
How to use SortBy method
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 ( | |
"fmt" | |
"github.com/thedevsaddam/gojsonq" | |
) | |
func main() { | |
jq := gojsonq.New().File("./sample-data.json") | |
res := jq.From("vendor.items").SortBy("price").Get() | |
fmt.Println(res) | |
// output: [map[id:<nil> name:HP core i3 SSD price:850] map[id:4 name:Fujitsu price:850] map[id:5 name:HP core i5 price:850 key:2300] map[id:6 name:HP core i7 price:950] map[id:3 name:Sony VAIO price:1200] map[id:1 name:MacBook Pro 13 inch retina price:1350] map[id:2 name:MacBook Pro 15 inch retina price:1700]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment