liveBook · Manning

Clojure.inspector

As explained in Clojure: The Essential Reference

clojure.inspector is a Clojure namespace providing a user interface for navigating and visualizing data structures.

clojure.inspector provides a small user interface for quickly navigating and visualizing structured Clojure data. It wraps data in a basic Java Swing window rather than transforming or analyzing it. section 22.2

Choose a visualization model according to the data shape:

  • Use a tree-like view for nested structures such as maps containing vectors and further maps. section 22.2
  • Use a tabular view for a group of collections with matching keys or matching sizes. section 22.2
  • Expect the first record or item list to establish the table size; inconsistent data shapes may display incorrectly. section 22.2
  • Treat the utility as a quick viewer: it offers little configuration or extensibility. section 22.2
(require '[clojure.inspector :refer [inspect-tree]]) ; #1
(inspect-tree {:a 1 :b 2 :c [1 2 3 {:d 4 :e 5 :f [6 7 8]}]}) ; #2

Inspect a nested map with inspect-tree to open a navigable visualization of its maps, vectors, and scalar values. section 22.2

(require '[clojure.inspector :refer [inspect-table]]) ; #1

(def events [{:time "2017-05-04T13:08:57Z" :msg "msg1"} ; #2
             {:time "2017-05-04T13:09:52Z" :msg "msg2"}
             {:time "2017-05-04T13:11:03Z" :msg "msg3"}
             {:time "2017-05-04T23:13:10Z" :msg "msg4"}
             {:time "2017-05-04T23:13:23Z" :msg "msg5"}])

(inspect-table events)
;; See image below

Inspect a uniform sequence of event maps with inspect-table to view matching records as a table. section 22.2

How Clojure: The Essential Reference covers it

How deep it goes
Explains tree, sequential, and tabular models plus shape requirements, but stops short of configuration or extensibility.
Examples
Demonstrates inspect-tree on nested data and inspect-table on uniform event maps.
What you can do after
Apply inspect-tree or inspect-table to open quick visual views of nested or uniform Clojure data.
How it connects
Connects structured data visualization with Java Swing and Clojure namespaces in the standard library.

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.