Oninit Logo
The Down System Specialists
+1-913-732-8892
+44-2081-337529
Partnerships Contact
Overview
Output Modes
HTML JSON PDF
Try It
Convert SQL
Download
Download
Reference
Glossary

Oninit® QueryLens — JSON output

--json (or -j) selects JSON output. The parser still walks the input and populates the object registry exactly as for HTML, but instead of emitting markup it writes a single JSON document describing every registered object plus a flat list of every resolved cross-reference. The output is the contract for downstream tooling.

sql2html --json < schema.sql > schema.json
dbschema -d mydb -ss | sql2html --json -h "mydb" -2 > mydb.json

Top-level shape

{
  "sql2html_version": "<semver>",
  "generated_at":     "<ISO-8601 UTC>",
  "source": {
    "title":      "<value of -h, or null>",
    "dbname":     "<-d default, or null>",
    "dbserver":   "<-i default, or null>",
    "owner":      "<-o default, or null>",
    "line_count": <int>
  },
  "objects":    [ ... ],
  "references": [ ... ]
}

objects[]

One record per registered object. Every record carries a type-specific attributes block plus a small envelope:

{
  "type":           "table" | "view" | "synonym" | "index" |
                    "trigger" | "routine" | "aggregate" | "udt" |
                    "constraint",
  "name":           "<identifier>",
  "qualified_name": { "dbserver": ..., "dbname": ..., "owner": ..., "object": ... },
  "anchor":         "{type}_{name}[_{line}]",
  "source":         { "line": <int>, "column": <int>, "byte_offset": <int> },
  "attributes":     { ... }
}

The anchor field is identical to the HTML/PDF anchor for that object, so a JSON-driven tool can emit links into the HTML or PDF output without re-deriving the scheme.

Type-specific attributes

TypeNotable attributes
tablecolumns (with datatype, not_null, default, check), primary_key, unique, foreign_keys (with references back-pointer), checks, fragmentation, lock_mode, extent_size, next_size, in_dbspace, is_temp.
viewdefinition_sql, with_check_option, referenced_tables.
indexon_table, unique, cluster, distinct, columns, access_method, fill_factor, fragmentation.
triggeron_table, events, update_columns, when_clause, plus per-clause action lists for before / for_each_row / after.
routinekind (procedure / function), params, returns, language, body_sql, and a calls[] list that resolves udr / uda targets.
udtBase type for opaque / row / distinct types, with the captured body verbatim.
synonymtarget as { name, anchor }.
constraintBack-pointer to the table it belongs to.

references[]

Independent of the per-object detail, every resolved cross-reference is also emitted as a flat list, so consumers can build a call graph or dependency diagram without re-parsing:

{
  "from": { "type": ..., "name": ..., "anchor": ... },
  "to":   { "type": ..., "name": ..., "anchor": ... },
  "kind": "column_type" | "fk_target" | "trigger_target" |
          "view_source" | "execute_procedure" | "synonym_target",
  "source_line": <int>
}

Stability contract

GuaranteeDetail
Field namingField names follow snake_case.
Optional fieldsEmitted as null rather than omitted, so consumers can rely on fixed shapes.
Versioningsql2html_version at the top is a semver string; the schema is versioned alongside the binary.
Anchor parityAnchor strings match the HTML and PDF outputs verbatim — one tool's links work against another tool's documents.

Interaction with other flags

--json ignores the effects of -h, -t, and -s on the output shape (the object list is the structured equivalent of the HTML summary; the title is captured as source.title). Two-pass mode (-2) is still honoured for reference resolution — it determines which forward references appear in references[].

To discuss how Oninit ® can assist please call on +1-913-732-8892 or alternatively just send an email specifying your requirements.


You get all this for free.. think about what you get if you pay us