mirror of https://github.com/tidwall/gjson.git
Fix bug where Result.Raw of literal 'false' was 'f'
This commit is contained in:
parent
ac7b6ae6f2
commit
922b012d22
2
gjson.go
2
gjson.go
|
@ -511,7 +511,7 @@ func tonum(json string) (raw string, num float64) {
|
|||
|
||||
func tolit(json string) (raw string) {
|
||||
for i := 1; i < len(json); i++ {
|
||||
if json[i] <= 'a' || json[i] >= 'z' {
|
||||
if json[i] < 'a' || json[i] > 'z' {
|
||||
return json[:i]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1101,3 +1101,12 @@ func TestGetMany48(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultRawForLiteral(t *testing.T) {
|
||||
for _, lit := range []string{"null", "true", "false"} {
|
||||
result := Parse(lit)
|
||||
if result.Raw != lit {
|
||||
t.Fatalf("expected '%v', got '%v'", lit, result.Raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue