What: | yajl-tcl |
Where: | http://flightaware.github.com/yajl-tcl/ |
Github project: | https://github.com/flightaware/yajl-tcl |
Description: | TCL-Binding for the yajl library. yajl (yet another json library) may create and parse JSON strings. |
Author: Karl Lehenbauer | |
Current version: | 1.6.1 released 21 Jun 2016 |
Download: | https://github.com/flightaware/yajl-tcl/v1.6.1.tar.gz |
Min libyajl version: | 1.0.8 (HaO supposes) |
HaO These are my test candidate experiences. I hope they may serve someone. Feel free to edit and clean-up any stupidity.
compile yajl-tcl 1.2 on SuSE-LinuxHaO 2012-07-10 Here are the steps (and eventual pitfalls) to build the yajltcl package on SuSE-Linux 11.4 32 bit.
./generic/yajltcl.h:25:5: error: expected specifier-qualifier-list before ‘yajl_gen_config’
cd /usr/local/lib ln -s /usr/lib/libyajl.so.1 libyajl.so
cannot find -lyajl
autoconf
./configure --prefix=/home/oehhar/test/yajl-install --exec-prefix=/home/oehhar/test/yajl-install
make
make install
The tcl package is contained in the folder /home/oehhar/test/yajl-tcl-install-lib/yajltcl1.2.
The package yjal-devel is not suitable, because the contained yajl version 1.0.7 is not sufficient. The following error arises:
./generic/yajltcl.c:550: Error: »yajl_gen_no_buf« not defined
The described symbol is defined since yajl 1.0.8.
Thus, yajl must be build by hand:
yum install cmake
cd /home/admin/test/yajl mkdir build cd build cmake .. make
-rw-rw-r-- libyajl_s.a lrwxrwxrwx libyajl.so -> libyajl.so.1 lrwxrwxrwx libyajl.so.1 -> libyajl.so.1.0.12 -rwxrwxr-x libyajl.so.1.0.12
cd /usr/local/lib64 cp /home/admin/test/yajl/build/yajl-1.0.12/lib/libyajl.so.1.0.12 . ln -s libyajl.so.1.0.12 libyajl.so.1 ln -s libyajl.so.1 libyajl.so
cd /usr/local/include cp -r /home/admin/test/yajl/build/yajl-1.0.12/include/* .
cd /home/admin/test/yajl-tcl autoconf
./configure --with-tcl=/usr/local/lib64 --mandir=/usr/local/man make
make install
/usr/bin/install: Aufruf von stat für „./doc/*.n“ nicht möglich: Datei oder Verzeichnis nicht gefunden
As apache-rivet does not include the library path /usr/local/lib64, an additional link is helpful:
cd /usr/lib64 ln -s /usr/local/lib64/libyajl.so.1
The library is searched here with the suffix .1. This is different to SuSE-Linux.
This yajl-tcl supports the current yajl version 2 library. so lets try compilation again:
HaO 2012-09-07 Here are the steps (and eventual pitfalls) to build the yajltcl package on SuSE-Linux 11.4 32 bit.
autoconf
./configure --prefix=/home/oehhar/test/yajl-install
make
make install
(as root). The tcl package is contained in the folder /usr/yajltcl1.3 and the folder /home/oehhar/test/yajl-install/include is created with no content.
Found rpm's only have version 1.0.7. So anyway, build by hand:
yum install cmake
cd /home/admin/test/yajl mkdir build cd build cmake .. make
-rw-rw-r-- libyajl_s.a lrwxrwxrwx libyajl.so -> libyajl.so.2 lrwxrwxrwx libyajl.so.2 -> libyajl.so.2.0.1 -rwxrwxr-x libyajl.so.2.0.1
cd /usr/local/lib64 cp /home/admin/test/yajl/build/yajl-1.0.12/lib/libyajl.so.2.0.1 . ln -s libyajl.so.2.0.1 libyajl.so.2 ln -s libyajl.so.2 libyajl.so
yajl-tcl will not compile without the last. If the last points to libyajl.so.1, a final package require yajltcl would output the error:
couldn't load file "/usr/local/lib64/yajltcl1.3/libyajltcl1.3.so": /usr/local/lib64/yajltcl1.3/libyajltcl1.3.so: undefined symbol: yajl_config
cd /usr/local/include cp -r /home/admin/test/yajl/build/yajl-2.0.1/include/* .
cd /home/admin/test/yajl-tcl autoconf
./configure --with-tcl=/usr/local/lib64 --mandir=/usr/local/man make
make install
As apache-rivet does not include the library path /usr/local/lib64, an additional link is helpful:
cd /usr/lib64 ln -s /usr/local/lib64/libyajl.so.2
The library is searched here with the suffix .2. This is different to SuSE-Linux.
yajltcl creates its objects as commands in the global namespace:
% namespace eval ns {yajl create y1} y1 % info commands y1 y1
Specify a namespace prefix to put the command is a distinct namespace:
% namespace eval ns {yajl create ::ns::y1} ::ns::y1 % info commands y1 % namespace eval ns {info commands y1} y1
(Complement to [L2 ]) The kept state is the count of open maps and arrays. Here is an example, where two array elements (which are maps) are streamed to stdout (using Rivet) one by one.
Here is the code for the first part:
yajl create y1 -beautify 1 y1 array_open y1 map_open string "name" string "Duck" string "surname" string "Donald" map_close puts [y1 get]
This will send:
[ { "name": "Duck", "surname": "Donald" }
Here is the code for the second and last array element:
y1 map_open string "name" string "Duck" string "surname" string "Daisy" map_close y1 array_close puts [y1 get] y1 reset
which will send:
, { "name": "Duck", "surname": "Daisy" } ]
You need resetif you want to reuse the y1command for further JSON objects.