[init] initial commit
This commit is contained in:
13
old/ctc/normalize.jq
Normal file
13
old/ctc/normalize.jq
Normal file
@ -0,0 +1,13 @@
|
||||
# Apply f to composite entities recursively using keys[], and to atoms
|
||||
def sorted_walk(f):
|
||||
. as $in
|
||||
| if type == "object" then
|
||||
reduce keys[] as $key
|
||||
( {}; . + { ($key): ($in[$key] | sorted_walk(f)) } ) | f
|
||||
elif type == "array" then map( sorted_walk(f) ) | f
|
||||
else f
|
||||
end;
|
||||
|
||||
def normalize: sorted_walk(if type == "array" then sort else . end);
|
||||
|
||||
normalize
|
Reference in New Issue
Block a user