-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define format in jq code #1228
base: master
Are you sure you want to change the base?
Define format in jq code #1228
Conversation
Rename the C builtin "format" to "_format". Define proxy function "format" in the file builtin.jq. To add a new format at runtime the user can redefine it.
7ec1d73
to
a1c93d9
Compare
Hi. This is a wonderful contribution. I may leave |
Great! |
I've realized there is a corner case that can cause |
Mimic how the [list] command in Tcl does it. This both gets rid of the redundant quoting of "{" and "}" and fixes the lack of necessary quoting in some cases. Add more tests for @tcl.
This makes the output format more idiomatic for Tcl.
Done. Now I forgot to say that I appreciate you complimenting this change. I am a fan of the purely functional language that jq has grown. |
Ping. Any updates on this? |
I'd love to see this in jq. I could see this formatter plugin being used to output YAML, hocon, dhall, and some others that are effectively supersets of JSON. |
The proposed change makes it easier to extend
format
with new formats (#1227). The reasoning is that it is often more straightforward to implement a serialization algorithm recursively in a high-level functional language than in C.I've implemented serialization to Tcl dictionaries (#685) in pure jq code as an example. This version differs slightly from the one in #685 to work around forward slash (
\
) escaping issues insrc/builtin.jq
.Perhaps the functionEdit: Done.totcl
should be renamed_totcl
.