j.q

Read JSON as a table: .j.read loads a document or JSON Lines from a file, a URL or a string, .j.info shows the schema it would use. `select from `:data.json` is the shortest spelling. .j.j and .j.k serialize and parse a value and need no \l pq.

Examples

select from `:https://www.timestored.com/data/sample/price.json where symbol like "*BTC"
select english, ineffective from `:https://www.timestored.com/data/sample/types.json where english like "F*"
`:t.json 0: enlist .j.j ([] a:1 2; b:("x";"y"))
select from `:t.json where a>1
.j.read["[{\"a\":1},{\"a\":2}]";::;::;()!()]

Entity Summary

EntitiesShort Description
.j.info[source;opts]The schema .j.read would use, as the dict its types argument takes, without loading the document.
.j.read[source;target;types;opts]Load a JSON document as a table.

Entity Details

.j.info[source;opts]

The schema .j.read would use, as the dict its types argument takes, without loading the document. A nested column, or one whose values do not share a q type, answers "*". Only sample_size records are read.

Return: a dict of column name to type char
Parameters:
  • opts - the options dict .j.read takes

Examples

.j.info["[{\"a\":1,\"b\":\"x\",\"o\":{\"p\":1}}]";()!()]

.j.read[source;target;types;opts]

Load a JSON document as a table. An object gives a one-row table, an array of objects one row per object, any other array a single `json column; a scalar or null signals 'type. Numbers keep the form they were written in (1 long, 1.0 float); a quoted number stays text. Records match by name, key order is free, an omitted key is null. Types are inferred from the first sample_size records and then fixed. Nested objects load recursively.

Parameters:
  • types - a dict of column to type char from "bgxhijefcspmdznuvt", or a type-char string for the whole schema; text parses through the CSV cell parser ("2026.08.25" under "d" is a date), anything else is cast; "*" leaves the column as read, " " drops it
  • opts - a dict; any unknown key signals 'option. path (symbol, long or a list of them: the value read out of each document, so `results, `data`items and (`data;`tables;0) are paths); format (`array, `newline_delimited or `auto); records (1b every value is a record, 0b never expand, or `auto); sample_size (long); xcol (symbol vector or dict renaming columns before the target is consulted); dateformat / timestampformat (the strptime subset .csv.read takes); ignore_errors, store_rejects, rejects_table (symbol, default `reject_errors)
  • source - `:data.json, a URL, the JSON text as a string, or a list of strings joined with newlines. On an http(s) URL a `#`results fragment spells the path option
  • target - :: answers the table; a symbol names a global table the rows are inserted into (created when absent, upserted when keyed; its schema outranks the sniff); a rank-3 lambda {[tblData;errData;misc] ...} is called once with the whole document. A symbol or lambda target answers the summary dict `rows`rejected`chunks`ignored`types
throws:
  • domain - a path step this document cannot take
  • mismatch - explicit types disagreeing with an existing target table
  • parse - a malformed document, or a framing the file does not have
  • type - a document that is not a table shape, a value that does not fit its column, or a key first seen after the sample
  • dup - a repeated key in one record
  • option - an unknown option key

Examples

.j.read["{\"a\":1}\n{\"a\":2}\n";::;::;()!()]
.j.read["{\"status\":\"OK\",\"results\":[{\"t\":\"2026.01.01\"}]}";::;(enlist `t)!enlist "d";(enlist `path)!enlist `results]
.j.read["[{\"a\":1}]";`t;::;()!()]