tidwall / gjson

Get JSON values quickly - JSON parser for Go
MIT License
13.95k stars 841 forks source link

"tag_name" is not successfully parsed #289

Closed Bellisario closed 1 year ago

Bellisario commented 2 years ago

I was trying to parse from latest GitHub releases, but I had a problem parsing "tag_name". Is this supported? Am I doing something wrong?


Here is a piece of what I'm trying to do:

var latestRaw = gjson.Get("{tag_name: \"1.1.0\"}", "tag_name").String()
// latestRaw is an empty string
spike014 commented 1 year ago

@Bellisario You lost "" between tag_name

package main

import (
    "fmt"

    "github.com/tidwall/gjson"
)

func main() {
    var latestRaw = gjson.Get("{\"tag_name\": \"1.1.0\"}", "tag_name").String()
    fmt.Println(latestRaw)
}
go run xxx.go
1.1.0
Bellisario commented 1 year ago

@spike014 thanks! I didn't realize I was missing double quotes... :disappointed: I'll close the issue!