-
Notifications
You must be signed in to change notification settings - Fork 892
Open
Description
go1.18.1 linux/amd64
gjson version 1.17.1
sample json:
{
"timestamp": "2024-04-17T05:39:04",
"MAIN.uptime": {
"description": "Child process uptime",
"flag": "c", "format": "d",
"value": 320
},
"MAIN.sess_conn": {
"description": "Sessions accepted",
"flag": "c", "format": "i",
"value": 8
},
"MAIN.sess_drop": {
"description": "Sessions dropped",
"flag": "c", "format": "i",
"value": 0
},
...
}
I want to retrieve the value inside MAIN.sess_conn, I've tried all this and it prints empty string:
fmt.Println(gjson.Get(json, gjson.Escape("MAIN.sess_conn"))) // prints blank line
fmt.Println(gjson.Get(json, `MAIN\.sess_conn.flag`)) // prints blank line
fmt.Println(gjson.Get(json, `MAIN\.sess_conn.value`).String()) // prints blank line
Even the Exists method returns false
fmt.Println(gjson.Get(json, `MAIN\.sess_conn.value`).Exists()) // prints false
fmt.Println(gjson.Get(json, `MAIN\.sess_conn`).Exists()) // prints false
Metadata
Metadata
Assignees
Labels
No labels