Verifies: SYS-REQ-008 [boundary]
(t *testing.T)
| 371 | |
| 372 | // Verifies: SYS-REQ-008 [boundary] |
| 373 | func TestRemoval4_EachKey_NestedObjectWithString(t *testing.T) { |
| 374 | // This tests the case where a string value contains braces |
| 375 | data := []byte(`{"skip":"has {braces}","want":"found"}`) |
| 376 | paths := [][]string{{"want"}} |
| 377 | |
| 378 | var foundValue []byte |
| 379 | EachKey(data, func(idx int, value []byte, vt ValueType, err error) { |
| 380 | if idx == 0 { |
| 381 | foundValue = value |
| 382 | } |
| 383 | }, paths...) |
| 384 | |
| 385 | if foundValue == nil { |
| 386 | t.Fatal("UNSAFE: EachKey failed to find 'want' after string with braces") |
| 387 | } |
| 388 | if string(foundValue) != "found" { |
| 389 | t.Fatalf("expected 'found', got %q", foundValue) |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | // ============================================================================= |
| 394 | // REMOVAL 5: `keys[level][0] != '['` removed in searchKeys |