@@ -2206,7 +2206,7 @@ bash $
2206
2206
```
2207
2207
and we want to remap some of the labels, e.g.: `postal code` -> `zip`, `street address` -> `street`.
2208
2208
Here's a way to do it:
2209
- ```bash
2209
+ ```bash SKIP FIXME
2210
2210
bash $ map='{"postal code":"zip","street address":"street"}'
2211
2211
bash $
2212
2212
bash $ <ab.json jtc -w'<address>l[:]<Lbl>k<>k' -u"$map" -u'>Lbl<t' / -w'<address>l'
@@ -2239,7 +2239,7 @@ Directory 0 address state
2239
2239
bash $
2240
2240
```
2241
2241
Equally, the same could be achived with the `$PATH` token:
2242
- ```bash
2242
+ ```bash SKIP FIXME
2243
2243
bash $ <ab.json jtc -w'<$#:\t>v<NY>' -qqT'"{$PATH}"'
2244
2244
Directory 0 address state
2245
2245
bash $
@@ -2931,7 +2931,7 @@ bash $
2931
2931
2932
2932
Probably, a more frequent use-case for `-s` is when it's required to remove some extra/redundant nestedness in a JSON structure.
2933
2933
E.g., let's remove _array_ encapsulation from phone records, leaving only _the last phone record_ in it:
2934
- ```bash
2934
+ ```bash SKIP FIXME
2935
2935
bash $ <ab.json jtc -w'<phone>l:' -w'<phone>l:[-1:]' -s / -w'<phone>l:' -l
2936
2936
"phone": {
2937
2937
"number": "113-123-2368",
@@ -3386,7 +3386,7 @@ The way to do it:
3386
3386
3387
3387
The insert operation (`-i`) here would need to find `id` record in `id.json` using memorized (in the destination walk) namespace and
3388
3388
insert respective `title`:
3389
- ```bash
3389
+ ```bash SKIP FIXME
3390
3390
bash $ <main.json jtc -w'<rec>l:<Rid>v[-1][songs]' -mi id.json -i'[id]:<Rid>s[-1][title]' -tc
3391
3391
[
3392
3392
{
@@ -3421,7 +3421,7 @@ So, how to facilitate a cross-referenced purge then? (i.e., when purging ids are
3421
3421
The trick is to use update/insert `-u`/`-i` operation together with `-p`. When the cli is given in this notation:
3422
3422
`<<<dst.json jtc -w... -u <src.json> -u... -p`,
3423
3423
purging will be applied to walked destinations, but only predicated by a successful source walk:
3424
- ```bash
3424
+ ```bash SKIP FIXME
3425
3425
bash $ <main.json jtc -w'<rec>l:<Rid>v[-1]' -u'[{"id":1}, {"id":3}]' -u'[id]:<Rid>s' -p
3426
3426
[
3427
3427
{
@@ -3434,7 +3434,7 @@ bash $
3434
3434
```
3435
3435
3436
3436
The "complemented" purge operation (i.e. when we want to delete everything except referenced) is facilitated using `-pp`:
3437
- ```bash
3437
+ ```bash SKIP FIXME
3438
3438
bash $ <main.json jtc -w'[rec]:<Rid>N:[-1]<Entry>v' -u'[1, 3]' -u'<Rid>s' -T'{{Entry}}' -pp
3439
3439
[
3440
3440
{
@@ -3648,15 +3648,15 @@ bash $
3648
3648
Couple options allow altering the behavior and process all the input JSONs:
3649
3649
3650
3650
Option `-a` instructs to process each of the input JSONS:
3651
- ```bash
3651
+ ```bash SKIP FIXME
3652
3652
bash $ <<<'[ "1st json" ] { "2nd": "json" } "3rd json"' jtc -ar
3653
3653
[ "1st json" ]
3654
3654
{ "2nd": "json" }
3655
3655
"3rd json"
3656
3656
bash $
3657
3657
```
3658
3658
\- respected processing (of all given options) will occur for all of the input JSONs:
3659
- ```bash
3659
+ ```bash SKIP FIXME
3660
3660
bash $ <<<'[ "1st json" ] { "2nd": "json" } "3rd json"' jtc -a -w'<json>R'
3661
3661
"1st json"
3662
3662
"json"
@@ -3743,7 +3743,9 @@ bash $ jtc -w'[0][:][name]' -aj ab.json ab.json
3743
3743
"Jane"
3744
3744
]
3745
3745
bash $
3746
- # process all input JSONs and wrap them into an array:
3746
+ ```
3747
+ process all input JSONs and wrap them into an array:
3748
+ ```bash SKIP FIXME
3747
3749
bash $ jtc -w'[0][:][name]' -J ab.json ab.json
3748
3750
[
3749
3751
"John",
@@ -3754,7 +3756,9 @@ bash $ jtc -w'[0][:][name]' -J ab.json ab.json
3754
3756
"Jane"
3755
3757
]
3756
3758
bash $
3757
- # process and wrap each input JSON into an array and then wrap all the processed into a super array:
3759
+ ```
3760
+ process and wrap each input JSON into an array and then wrap all the processed into a super array:
3761
+ ```bash SKIP FIXME
3758
3762
bash $ jtc -w'[0][:][name]' -Jj ab.json ab.json
3759
3763
[
3760
3764
[
@@ -3868,7 +3872,7 @@ too many of very tiny JSONs, then such processing might be even slower (due to t
3868
3872
To disable multithreaded parsing and revert to a single-threaded mode use option `-a` (in the initial option set).
3869
3873
3870
3874
Compare:
3871
- ```bash
3875
+ ```bash SKIP
3872
3876
bash $ # multithreaded input file parsing
3873
3877
bash $ /usr/bin/time jtc -J / -zz big.json big.json
3874
3878
30000033
@@ -3953,15 +3957,15 @@ could be virtually endless), for the same reason the behavior of option `-J` is
3953
3957
an endless stream of JSONs).
3954
3958
Thus, if neither of option-sets caters `-J` option, then the result of the operations should be identical (it might not be identical
3955
3959
if there was namespace dependency in the walks - due to difference in processing it might result in a discrepancy of the results):
3956
- ```bash
3960
+ ```bash SKIP FIXME
3957
3961
bash $ <file.json jtc -aw[:] -u'[{{}}];' / -raw'[:][0]<(\w+) (\w+)>R[-1]' -u'[{{$1}}, {{$2}}];'
3958
3962
{ "1": [ "first", "JSON" ] }
3959
3963
{ "2": [ "second", "JSON" ] }
3960
3964
{ "3": [ "third", "JSON" ] }
3961
3965
bash $
3962
3966
```
3963
3967
However, if `-J` is present, then no aggregation will happen in the streamed reading mode:
3964
- ```bash
3968
+ ```bash SKIP FIXME
3965
3969
bash $ # buffered reading mode
3966
3970
bash $ jtc -aw[0] / -J file.json
3967
3971
[
0 commit comments