mirror of
https://github.com/wader/fq.git
synced 2024-11-23 09:56:07 +03:00
051a70bd4b
All other ranges and slicing uses exclusive end so i think it make sense to make it consistent. Update docs and add additional example for non-byte-aligned field. Also fixes issue showing zero bit ranges as start-NA.
126 lines
2.3 KiB
Plaintext
126 lines
2.3 KiB
Plaintext
$ fq -i -n '"[]" | json'
|
|
json> (.) | ., tovalue, toactual, tosym, type, length?
|
|
[]
|
|
[]
|
|
[]
|
|
null
|
|
"array"
|
|
0
|
|
json> (.)[0] | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)[-1000] | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)[1000] | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)[1:3] | ., type, length?
|
|
[]
|
|
"array"
|
|
0
|
|
json> (.)[0:-1] | ., type, length?
|
|
[]
|
|
"array"
|
|
0
|
|
json> (.)[-1000:2000] | ., type, length?
|
|
[]
|
|
"array"
|
|
0
|
|
json> (.)["test"] | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> [(.)[]] | type, length?
|
|
"array"
|
|
0
|
|
json> (.) | keys
|
|
[]
|
|
json> (.) | has("a")
|
|
error: cannot check whether array has a key: a
|
|
json> (.) | has(0)
|
|
false
|
|
json> (.) | type
|
|
"array"
|
|
json> (.) | tonumber
|
|
error: tonumber cannot be applied to: array
|
|
json> (.) | tostring
|
|
"[]"
|
|
json> (.) + ""
|
|
error: cannot add: array ([]) and string ("")
|
|
json> (.) + 1
|
|
error: cannot add: array ([]) and number (1)
|
|
json> (.)._start | ., type, length?
|
|
0
|
|
"number"
|
|
0
|
|
json> (.)._stop | ., type, length?
|
|
16
|
|
"number"
|
|
16
|
|
json> (.)._len | ., type, length?
|
|
16
|
|
"number"
|
|
16
|
|
json> (.)._name | ., type, length?
|
|
""
|
|
"string"
|
|
0
|
|
json> (.)._actual | ., type, length?
|
|
[]
|
|
"array"
|
|
0
|
|
json> (.)._sym | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)._description | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)._path | ., type, length?
|
|
[]
|
|
"array"
|
|
0
|
|
json> (.)._bits | ., type, length?
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
|
0x0|5b 5d| |[]| |.: raw bits 0x0-0x2 (2)
|
|
"string"
|
|
16
|
|
json> (.)._bytes | ., type, length?
|
|
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
|
|
0x0|5b 5d| |[]| |.: raw bits 0x0-0x2 (2)
|
|
"string"
|
|
2
|
|
json> (.)._error | ., type, length?
|
|
null
|
|
"null"
|
|
0
|
|
json> (.)._gap | ., type, length?
|
|
false
|
|
"boolean"
|
|
json> (.).a = 1
|
|
error: setpath(["a"]; 1) cannot be applied to []: expected an object but got: array ([])
|
|
json> (.)[0] = 1
|
|
[
|
|
1
|
|
]
|
|
json> (.).a |= empty
|
|
error: delpaths([["a"]]) cannot be applied to []: expected an object but got: array ([])
|
|
json> (.)[0] |= empty
|
|
[]
|
|
json> (.) | setpath(["a"]; 1)
|
|
error: setpath(["a"]; 1) cannot be applied to []: expected an object but got: array ([])
|
|
json> (.) | setpath([0]; 1)
|
|
[
|
|
1
|
|
]
|
|
json> (.) | delpaths([["a"]])
|
|
error: delpaths([["a"]]) cannot be applied to []: expected an object but got: array ([])
|
|
json> (.) | delpaths([[0]])
|
|
[]
|
|
json> ^D
|