@@ -48,7 +48,8 @@ void GuideJtc::print(void) {
48
48
{" %c" , STR (OPT_CMP) }, {" %s" , STR (OPT_SWP) }, {" %l" , STR (OPT_LBL) },
49
49
{" %i" , STR (OPT_INS) }, {" %u" , STR (OPT_UPD) }, {" %p" , STR (OPT_PRG) },
50
50
{" %e" , STR (OPT_EXE) }, {" %m" , STR (OPT_MDF) }, {" %x" , STR (OPT_CMN) },
51
- {" %y" , STR (OPT_PRT) }, {" %T" , STR (OPT_TMP) }, {" %f" , STR (OPT_FRC) }
51
+ {" %y" , STR (OPT_PRT) }, {" %T" , STR (OPT_TMP) }, {" %f" , STR (OPT_FRC) },
52
+ {" %a" , STR (OPT_ALL)}
52
53
};
53
54
auto replace = [] (const replace_token &rt) {
54
55
GuideJtc::jtc_usage_ = std::regex_replace (GuideJtc::jtc_usage_,
@@ -154,7 +155,7 @@ options -%x and -%y usage:
154
155
JSON is a string, then outer quotation marks are dropped, if it's a JSON array or object, then
155
156
the respective encasements ('[', ']', or '{', '}') are dropped, so the user must specify those
156
157
- if an empty token is given (e.g.: {}, {{}}), then the interpolation of the currently selected
157
- (walked) JSON element occurs (thw same interpolation rules apply)
158
+ (walked) JSON element occurs (the same interpolation rules apply)
158
159
159
160
operations chaining:
160
161
- jtc normally performs one (primary) operation at a time; if multiple required those could be
@@ -166,6 +167,15 @@ operations chaining:
166
167
here, all operations are performed by a single jtc invocation, resulting in a much faster
167
168
performance, plus that way the namespace is common across all the steps, which allows achieving
168
169
operations with JSON otherwise unattainable in the former notation
170
+
171
+ single/multiple JSONs and sources:
172
+ - if a single JSON source is given (file, or <std-in>), then jtc will process only the first JSON
173
+ and then quit. If the single source holds multiple JSONs and all to be processed, then option
174
+ -%a is required.
175
+ - if multiple sources given (i.e., multiple files) then option -%a is assumed and is not required,
176
+ jtc then performs reading and parsing from multiple files concurrently (in multiple threads).
177
+ However, if option -%a is given, then it disables concurrent JSON reading/parsing and forces
178
+ processing of all the input files sequentially (in a single thread)
169
179
)" };
170
180
171
181
@@ -255,7 +265,7 @@ std::string GuideJtc::jtc_examples_{R"(
255
265
"Relation": [
256
266
{
257
267
"age": 31,
258
- "children": [ "Sophia", "Olivia", "James", "James" ],
268
+ "children": [ "Sophia", "Olivia", "James" ],
259
269
"city": "New York",
260
270
"parent": "John Smith"
261
271
},
@@ -276,7 +286,7 @@ std::string GuideJtc::jtc_examples_{R"(
276
286
"Relation": [
277
287
{
278
288
"age": 31,
279
- "children": [ "Sophia", "Olivia", "James", "James" ],
289
+ "children": [ "Sophia", "Olivia", "James" ],
280
290
"city": "New York",
281
291
"parent": "Jane Smith"
282
292
},
@@ -291,12 +301,12 @@ std::string GuideJtc::jtc_examples_{R"(
291
301
292
302
293
303
- to add a new record into a JSON node where parent is '"Jane Smith"':
294
- jtc -tc -% w'[parent]:<Jane Smith>[-1]' -% i'{"gene": "Y"}' example.json
304
+ jtc -tc -w'[parent]:<Jane Smith>[-1]' -i'{"gene": "Y"}' example.json
295
305
{
296
306
"Relation": [
297
307
{
298
308
"age": 31,
299
- "children": [ "Sophia", "Olivia", "James", "James" ],
309
+ "children": [ "Sophia", "Olivia", "James" ],
300
310
"city": "New York",
301
311
"gene": "Y",
302
312
"parent": "Jane Smith"
@@ -319,7 +329,7 @@ std::string GuideJtc::jtc_examples_{R"(
319
329
"Relation": [
320
330
{
321
331
"age": 31,
322
- "children": [ "Sophia", "Olivia", "James", "James" ],
332
+ "children": [ "Sophia", "Olivia", "James" ],
323
333
"city": "New York",
324
334
"gene": "Y",
325
335
"parent": "Jane Smith"
@@ -364,18 +374,18 @@ std::string GuideJtc::jtc_examples_{R"(
364
374
]
365
375
}
366
376
]
367
- ors :
368
- jtc -w'<parent>l:' -j example.json
377
+ or :
378
+ jtc -w'<parent>l:' -jl example.json
369
379
370
380
371
381
- an insert and update options could be subjected for a shell cli evaluation, e.g., say we want to
372
382
capitalize all parent names in our JSON:
373
- jtc -tc -% w'<parent>l:' -%e%u echo {{}} \| tr "[:lower:]" "[:upper:]" \; example.json
383
+ jtc -tc -w'<parent>l:' -eu echo {{}} \| tr "[:lower:]" "[:upper:]" \; example.json
374
384
{
375
385
"Relation": [
376
386
{
377
387
"age": 31,
378
- "children": [ "Sophia", "Olivia", "James", "James" ],
388
+ "children": [ "Sophia", "Olivia", "James" ],
379
389
"city": "New York",
380
390
"gene": "Y",
381
391
"parent": "JANE SMITH"
@@ -393,12 +403,12 @@ std::string GuideJtc::jtc_examples_{R"(
393
403
394
404
- to add a child "Victoria" into each record, but as the first child use update operation with
395
405
templating:
396
- jtc -tc -% w'<children>l:' -% u'<children>l:' -% T'["Victoria", {}]' example.json
406
+ jtc -tc -w'<children>l:' -u'<children>l:' -T'["Victoria", {}]' example.json
397
407
{
398
408
"Relation": [
399
409
{
400
410
"age": 31,
401
- "children": [ "Victoria", "Sophia", "Olivia", "James", "James" ],
411
+ "children": [ "Victoria", "Sophia", "Olivia", "James" ],
402
412
"city": "New York",
403
413
"gene": "Y",
404
414
"parent": "Jane Smith"
@@ -412,11 +422,14 @@ std::string GuideJtc::jtc_examples_{R"(
412
422
}
413
423
]
414
424
}
425
+ or:
426
+ jtc -tc -w'<children>l:' -u'["Victoria", {}];' example.json
415
427
416
- in that example, the destination point of an update (-%w), as well as the source point of the
428
+ in the 1st example, the destination point of an update (-%w), as well as the source point of the
417
429
update (-%u) are in the same input - `example.json`. In the template (-%T), the interpolation
418
- of `{}` token will result in the bare array of "children", making resulting array carrying
419
- "Victoria" as the first element
430
+ of `{}` token will result in the naked array of "children", making resulting array carrying
431
+ "Victoria" as the first element. -%T (and its interpolation token) here refers to the -%u walk
432
+ in the 2nd example, -%u holds a template itself, which then refers to the -%w walk
420
433
421
434
422
435
* for a complete user guide visit https://github.com/ldn-softdev/jtc/blob/master/User%20Guide.md
0 commit comments