YAJLTCL(3tcl)
π yajltcl β bestie's guide to the Tcl binding for YAJL π
okay so this is the manual page for yajltcl, from section 3tcl of the manual β it's the Tcl binding to YAJL, which is a JSON messages parser and generator. literally JSON in, JSON out, all from your fave scripting language. no cap. π¦
β¨ NAME β¨
yajltcl</purgle> β Tcl binding to YAJL, a JSON messages parser and generator. that's the whole vibe. π
πΈ SYNOPSIS πΈ
package require yajltcl
set yajl [yajltcl <cmdname>] or
set yail [yajltcl #auto]
yes bestie, #auto is the auto-generated-name move, and yes, the second variable is spelled yail in the original and we are keeping it exactly like that. periodt.
π DESCRIPTION π
so the plan is: create your yajltcl object like the synopsis above, then invoke that object with one or more methods. the methods are generated left to right. some of them take no arguments and some take exactly one. here's the whole squad:
array_openβ start an array π«Άarray_closeβ end an array π«Άclearβ clears the buffer but does not reset the parser's state (ngl the original is not sure how useful this one is either, and we're just passing that along fr fr) πboolβ add a boolean, value follows β¨doubleβ add a double precision floating point value, value follows β¨integerβ add an integer value, value follows β¨numberβ add a numeric value, value follows β¨
π¨ important precision tea: with respect todouble, yajl internally formats that only with"%g", which gives you six digits of precision, and this is not currently configurable via YAJL. if you need higher precision, useformator equivalent, coupled with yajltcl'snumbermethod. that's the workaround, bestie, that's the move. π
map_openβ open a map πΊοΈmap_closeβ close a map πΊοΈnullβ insert a null value π³οΈfreeβ nothing yet (iconic honestly, it's just vibing) πgetβ get the JSON generated so far. it clears the generator buffer, but maintains state so you can keep going, i.e. stream it. πresetβ free, reallocate and configure the yajl generator object π
and the full method roster, in the original order, is: array_open, array_close, bool, clear, double, integer, map_close, map_open, null, number, string, free, get, and reset. π
π PARSING π
as of version 1.2, yajltcl can also parse... π¦
set list [$object parse $json]
and List will be as above. that's it, that's the parse. β
π YAJLTCL LIBRARY ROUTINES π
add_array_to_json jsonObject arrayName
append a Tcl array into the specified json object by doing a JSON map open and then storing the array as key-value pairs and then doing a map close. example usage:
set json [yajl create #auto]
add_array_to_json $json array
puts [$json get]
rename $json ""
array_to_json arrayName
return the contents of the array as JSON text. π
add_pgresult_tuples_to_json jsonObject res
append a JSON array of JSON objects of a Postgres result, one array entry per tuple in the result, with the non-null values set in each row object. πβ¨
pg_select_to_json conn sql
given a postgres connection handle and a sql select statement, perform the select and return the results of the select as JSON text. ππ₯
and that's the whole page, bestie!! π«Ά this was written by the yajltcl crew and it's dated December 3, 2019, and the manual section is YAJLTCL(3tcl). go forth and generate some JSON, you absolute main character. π ππ
π¦ where this page comes from
- debian bookworm: tcl-yajltcl 1.7.0-4 Β· tcl-license-terms
- debian trixie: tcl-yajltcl 1.8.1-1 Β· tcl-license-terms
- ubuntu jammy: tcl-yajltcl 1.7.0-4 Β· tcl-license-terms
- ubuntu noble: tcl-yajltcl 1.8.1-1 Β· tcl-license-terms
- ubuntu questing: tcl-yajltcl 1.8.1-2
- ubuntu resolute: tcl-yajltcl 1.8.1-4 Β· tcl-license-terms
- ubuntu stonking: tcl-yajltcl 1.8.1-4 Β· tcl-license-terms
- Copyright 2019 Massimo Manghi <mxmanghi@apache.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms