We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d94c308 commit a6e58b8Copy full SHA for a6e58b8
lib/json.bash
@@ -98,9 +98,8 @@ JSON.object() {
98
JSON._object() {
99
local key=$1
100
if [[ -n $key && $key != "/" ]]; then
101
- key=${key/\//\\/}
102
- grep -E "^$key/" |
103
- sed "s/^$key//"
+ key=${key//\//\\/}
+ sed -n "s/^$key//p"
104
else
105
cat
106
fi
test/keys.t
@@ -2,7 +2,7 @@
2
3
source test/setup
4
5
-use Test::More tests 5
+use Test::More tests 6
6
use JSON
7
8
tree1=$(cat test/keys.json | JSON.load)
@@ -28,3 +28,8 @@ is "$keys" \
28
keys="$(JSON.keys '/' tree1)"
29
is "$keys" "description"$'\n'"files" \
30
"JSON.keys '/'" #'
31
+
32
+keys="$(JSON.keys '/files/file 2.txt' tree1)"
33
+is "$keys" \
34
+ "content"$'\n'"type" \
35
+ "JSON.keys '/files/file 2.txt'" #'
0 commit comments