You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've implemented a function that produces Tcl dictionary output from jq (see man n tcl for an overview of the format). You will find it below.
If possible, I'd like to have it ship as part of jq (e.g., as @tcl). I've looked and all the existing export formats (@csv, @tsv, etc.) seem to be implemented in C rather than jq itself, so before I start working on a pull request I would like to ask: would be acceptable if I implemented @tcl as a call from f_format to a function stored in jq_builtins or should I avoid that and translate it to plain C?
def totcl:
if type == "array" then
# Convert array to object with keys 0, 1, 2... and process
# it as object.
[range(0;length) as $i
| {key: $i | tostring, value: .[$i]}]
| from_entries
| totcl
elif type == "object" then
.
| to_entries
| map("{\(.key)} {\(.value | totcl)}")
| join(" ")
else
tostring
| gsub("{";"\\{")
| gsub("}";"\\}")
end;
. | totcl # Use example.
The text was updated successfully, but these errors were encountered:
Hey there, this is cool! Yes, perhaps format should be jq-coded, calling out to the C-coded form only for the C-coded formats. This should be easy to do, I think, and would be something like:
def format(fmt): if fmt == "@tcl" then ... else _format(fmt) end;
I've implemented a function that produces Tcl dictionary output from jq (see man n tcl for an overview of the format). You will find it below.
If possible, I'd like to have it ship as part of jq (e.g., as
@tcl
). I've looked and all the existing export formats (@csv
,@tsv
, etc.) seem to be implemented in C rather than jq itself, so before I start working on a pull request I would like to ask: would be acceptable if I implemented@tcl
as a call fromf_format
to a function stored injq_builtins
or should I avoid that and translate it to plain C?The text was updated successfully, but these errors were encountered: