1
1
mirror of https://github.com/wader/fq.git synced 2024-11-30 09:58:13 +03:00
fq/pkg/interp/testdata/value_array.fqtest
Mattias Wadman 0c7fa090b0 gojq: Initial update support
decode value give no updateable error
JQValue json value tries to replicate behaveior
2021-09-12 13:08:50 +02:00

202 lines
5.0 KiB
Plaintext

/test.mp3:
$ fq -i -d mp3 . /test.mp3
mp3> .headers | ., tovalue, type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.headers: [1]
0x00|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..| [0]: {} (id3v2)
* |until 0x2c.7 (45) | |
[
{
"flags": {
"experimental_indicator": false,
"extended_header": false,
"unsynchronisation": false,
"unused": 0
},
"frames": [
{
"flags": {
"compression": false,
"data_length_indicator": false,
"encryption": false,
"file_alter_preservation": false,
"grouping_identity": false,
"read_only": false,
"tag_alter_preservation": false,
"unsync": false,
"unused0": 0,
"unused1": 0,
"unused2": 0
},
"id": "TSSE",
"size": 15,
"text": "Lavf58.45.100",
"text_encoding": 3
}
],
"magic": "ID3",
"padding": null,
"revision": 0,
"size": 35,
"version": 4
}
]
"array"
1
mp3> .headers[0] | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |.headers[0]: {} (id3v2)
0x00|49 44 33 |ID3 | magic: "ID3" (Correct)
0x00| 04 | . | version: 4
0x00| 00 | . | revision: 0
0x00| 00 | . | flags: {}
0x00| 00 00 00 23 | ...# | size: 35
0x00| 54 53 53 45 00 00| TSSE..| frames: [1]
0x10|00 0f 00 00 03 4c 61 76 66 35 38 2e 34 35 2e 31|.....Lavf58.45.1|
0x20|30 30 00 |00. |
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... | padding: Correct (none) (zero padding)
"object"
7
mp3> .headers[-1000] | ., type, length?
null
"null"
0
mp3> .headers[1000] | ., type, length?
null
"null"
0
mp3> .headers[1:3] | ., type, length?
[]
"array"
0
mp3> .headers[0:-1] | ., type, length?
[]
"array"
0
mp3> .headers[-1000:2000] | ., type, length?
[
{
"flags": {
"experimental_indicator": false,
"extended_header": false,
"unsynchronisation": false,
"unused": 0
},
"frames": [
{
"flags": {
"compression": false,
"data_length_indicator": false,
"encryption": false,
"file_alter_preservation": false,
"grouping_identity": false,
"read_only": false,
"tag_alter_preservation": false,
"unsync": false,
"unused0": 0,
"unused1": 0,
"unused2": 0
},
"id": "TSSE",
"size": 15,
"text": "Lavf58.45.100",
"text_encoding": 3
}
],
"magic": "ID3",
"padding": null,
"revision": 0,
"size": 35,
"version": 4
}
]
"array"
1
mp3> .headers["test"] | ., type, length?
error: expected an object with key "test" but got: array
mp3> [.headers[]] | type, length?
"array"
1
mp3> .headers | keys
[
0
]
mp3> .headers | has("a")
error: cannot check whether array has a key: a
mp3> .headers | has(0)
true
mp3> .headers | type
"array"
mp3> .headers | tonumber
error: tonumber cannot be applied to: array
mp3> .headers | tostring
error: tostring cannot be applied to: array
mp3> .headers + ""
error: cannot add: array ([{"flags":{"experimental_ ...]) and string ("")
mp3> .headers + 1
error: cannot add: array ([{"flags":{"experimental_ ...]) and number (1)
mp3> .headers._start | ., type, length?
0
"number"
0
mp3> .headers._stop | ., type, length?
360
"number"
360
mp3> .headers._len | ., type, length?
360
"number"
360
mp3> .headers._name | ., type, length?
"headers"
"string"
7
mp3> .headers._symbol | ., type, length?
""
"string"
0
mp3> .headers._description | ., type, length?
""
"string"
0
mp3> .headers._path | ., type, length?
[
"headers"
]
"array"
1
mp3> .headers._bits | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x00|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..|
<360 bits>
"buffer"
360
mp3> .headers._bytes | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x00|49 44 33 04 00 00 00 00 00 23 54 53 53 45 00 00|ID3......#TSSE..|
<45 bytes>
"buffer"
45
mp3> .headers._error | ., type, length?
null
"null"
0
mp3> .headers._unknown | ., type, length?
false
"boolean"
mp3> .headers.a = 1
error: cannot update key a for array
mp3> .headers[0] = 1
error: cannot update key 0 for array
mp3> .headers.a |= empty
error: expected an object with key "a" but got: array
mp3> .headers[0] |= empty
error: cannot update key 0 for array
mp3> .headers | setpath(["a"]; 1)
error: cannot update key a for array
mp3> .headers | setpath([0]; 1)
error: cannot update key 0 for array
mp3> .headers | delpaths([["a"]])
error: cannot update key a for array
mp3> .headers | delpaths([[0]])
error: cannot update key 0 for array
mp3> ^D