Unicon Class Library

_images/unicon.png

Index Unicon

UCL

The Unicon Class Library. A collection of Unicon programs, procedures, classes, methods, and supporting data. Includes the Unicon GUI classes by Robert Parlett, JSON support by Gigi Young, development tools, and many more useful extensions to core Unicon.

The library is also very useful for learning Unicon, with lots of well written Unicon source code.

The UCL source code included with the Unicon distribution is licensed under the Lesser GNU General Public License.

Like the IPL, knowing how to best leverage the Unicon Class Library can take some time. There are hundreds of supporting classes to take advantage of.

Find all the sources in the uni/lib directory of the Unicon source tree. Most of these are precompiled with an installation, easily included in applications with a simple link expression.

JSON

A contribution by Gigi Young and Clinton Jeffery, provides access to JSON handling.

Use link json to include the features. There are high level (thread safe) functions of jtou() and utoj(). These convert JSON to Unicon and Unicon to JSON data structures, respectively.

A technical report for Unicon JSON, UTR20, is hosted at http://unicon.org/utr/utr20.pdf

Quick sample, from the technical report:

#
# json-hello.icn, demonstrate the json.icn Unicon Class Library contribution.
# By Gigi Young and Clinton Jeffery.
#
link json
procedure main()
   # JSON string to Unicon table
   T := jtou("{\"To\": \"world\", \"Say\": \"Hello, \"}")
   write(T["Say"], T["To"])

   # Unicon table to JSON string
   TU := table()
   TU["one"] := 1
   TU["two"] := 2
   TU["list"] := [1,2,3]
   TU["table"] := table()
   write("Unicon table in JSON: ", utoj(TU))
end

examples/json-trial.icn

prompt$ unicon -s json-trial.icn -x
Hello, world
Unicon table in JSON: {"two":2,"table":{},"one":1,"list":[1,2,3]}

Index | Previous: Icon Program Library | Next: Use case scenarios