(json string)
| 3370 | } |
| 3371 | |
| 3372 | func revSquash(json string) string { |
| 3373 | // reverse squash |
| 3374 | // expects that the tail character is a ']' or '}' or ')' or '"' |
| 3375 | // squash the value, ignoring all nested arrays and objects. |
| 3376 | i := len(json) - 1 |
| 3377 | var depth int |
| 3378 | if json[i] != '"' { |
| 3379 | depth++ |
| 3380 | } |
| 3381 | if json[i] == '}' || json[i] == ']' || json[i] == ')' { |
| 3382 | i-- |
| 3383 | } |
| 3384 | for ; i >= 0; i-- { |
| 3385 | switch json[i] { |
| 3386 | case '"': |
| 3387 | i-- |
| 3388 | for ; i >= 0; i-- { |
| 3389 | if json[i] == '"' { |
| 3390 | esc := 0 |
| 3391 | for i > 0 && json[i-1] == '\\' { |
| 3392 | i-- |
| 3393 | esc++ |
| 3394 | } |
| 3395 | if esc%2 == 1 { |
| 3396 | continue |
| 3397 | } |
| 3398 | i += esc |
| 3399 | break |
| 3400 | } |
| 3401 | } |
| 3402 | if depth == 0 { |
| 3403 | if i < 0 { |
| 3404 | i = 0 |
| 3405 | } |
| 3406 | return json[i:] |
| 3407 | } |
| 3408 | case '}', ']', ')': |
| 3409 | depth++ |
| 3410 | case '{', '[', '(': |
| 3411 | depth-- |
| 3412 | if depth == 0 { |
| 3413 | return json[i:] |
| 3414 | } |
| 3415 | } |
| 3416 | } |
| 3417 | return json |
| 3418 | } |
| 3419 | |
| 3420 | // Paths returns the original GJSON paths for a Result where the Result came |
| 3421 | // from a simple query path that returns an array, like: |
no outgoing calls
searching dependent graphs…