Fix #280: from_entries of [] is null, should be {}

This commit is contained in:
Nicolas Williams committed 2014-06-16 22:40:44 -05:00
1 parent ea63d5d3c2
commit f58f771660
1 file changed
+1 -1
+1 -1
View File
@@ -707,7 +707,7 @@ static const char* const jq_builtins[] = {
"def recurse(f): ., (f | select(. != null) | recurse(f));", "def recurse(f): ., (f | select(. != null) | recurse(f));",
"def recurse_down: recurse(.[]?);", "def recurse_down: recurse(.[]?);",
"def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];", "def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];",
"def from_entries: map({(.key): .value}) | add;", "def from_entries: map({(.key): .value}) | add | .//={};",
"def with_entries(f): to_entries | map(f) | from_entries;", "def with_entries(f): to_entries | map(f) | from_entries;",
"def reverse: [.[length - 1 - range(0;length)]];", "def reverse: [.[length - 1 - range(0;length)]];",
"def indices(i): if type == \"array\" and (i|type) == \"array\" then .[i] elif type == \"array\" then .[[i]] else .[i] end;", "def indices(i): if type == \"array\" and (i|type) == \"array\" then .[i] elif type == \"array\" then .[[i]] else .[i] end;",