- Fixed issue with the JSONPath engine that caused object members named
values
with an array as the value, to return malformed paths ending in a[NaN]
-
OPTIND
andOPTARG
now declared as local variables withinjpt
due to issues when embedded inbash
scripts which uses global variables for them that are not sanitized within functions as it is forzsh
-
Minified version (jpt.min) was not ES5 due to changes in Closure (my bad) this caused issues in macOS 10.15 and under, this has been addressed.
- Reverted back to standard
/usr/bin
sh-bang paths, usingenv
can cause issues with upgraded shells
- Textual output (-T) now escapes solidus/backslashes \ with \\, when encoding (-E) for escaped formats (hex, octal, Unicode code points) or if whitespace escaping (-e) is specified but without -E encoding.
- fixed handling of keypaths with multiple escaped periods
-
Support and refinements for JSONPath "existence test" in filter expressions for nodes that contain data that evaluates as "falsey" (e.g. zero, negative numbers, empty strings, null, and false).
-
Negation operator (!) now works on both existence tests and standard comparison operations in filter expressions
-
For example:
% jpt -i0 '$[?(@.falsey)]' <<< '[{"falsey":0}]'
{"falsey":0}
% jpt -i0 $'$[?([email protected] && [email protected])]' <<< '[{"a":5,"b":9},{"c":3,"d":4}]'
{"c":3,"d":4}
-W
flag to also encode whitespace when outputting encoded text with-T
and-E <value>
where the modes typically only encodes non-ASCII text, for example octal output suitable for fstab:
% jpt -S -W -T -EO <<< 'Macintosh HD'
Macintosh\040HD
- Fixed bug in closure compiled minified version that affected filters. Now using whitespace only compilation level.
- More forgiving of
jq
-isms in queries: a single.
acts as root,.[
at the beginning is treated as$[
- Disables xtrace while inside the function for quieter debugging of your scripts
- plutil-style keypaths are now accepted
- jq-style paths that begin with
[
or.
are now accepted (jq pipes|
are not support) jpt
function now runs in a subshell, so shell variables no longer need uselocal
to avoid name collisions with global variables- Cleanup of shell syntax for
test
from chained-a
and-o
style boolean operators to discrete&&
and||
expressions
- Help text from
jpt -h
now pipes throughless
for pagination (and has one less typo!) - If no inputs are detected (via file path, pipe, or file redirection)
jpt
displays info and exits instead of waiting for input
% jpt
jpt (v1.0.1) - JSON Power Tool (https://github.com/brunerd/jpt)
Usage: jpt [options] [query] [filepath] (see jpt -h for more help...)
- Fixes pkg installer bug if
/usr/local/bin
did not exist
Notable new features include:
- The ability to parse and generate JSON Text Sequences, NDJSON/JSON Lines, and "concatenated JSON"
- The ability to parse "JSON5" and rehabilitate back to JSON with conversion options for NaN and Infinity number types
- Two new merge modes:
merge0
to merge object properties that DO NOT intersect with source JSON andmerge1
to merge only ones that do - Revamped hex, binary and octal numeric encoding modes using ECMAScript notation
- Continued support for JSONPath object literals (-L mode) now with record separator support for multiple JSON texts
- Truncated JSON can be detected and capped for recovery.
Read more about jpt at: https://www.brunerd.com/blog/category/projects/jpt/
Installation Notes: The package is not notarized (because it breaks on older macOS). Simply right-click in Finder and choose Open to allow Gatekeeper bypass. You can also remove the quarantine by opening Terminal and running this command: xattr -rc <drag in file from Finder>
The installer pkg includes both the full script (jpt) and the minified version (jpt.min) installed to /usr/local/jpt/ with a soft link to jpt created in /usr/local/bin. The minified version jpt.min
is for easy inclusion in your shell scripts while jpt
is for standalone use.