Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
Importing JSON
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The below JSON data represents two author records that may have been exported previously, by jOOQ's exporting functionality:
{"fields" :[{"name":"ID","type":"INTEGER"},
{"name":"AUTHOR_ID","type":"INTEGER"},
{"name":"TITLE","type":"VARCHAR"}],
"records":[[1,1,"1984"],
[2,1,"Animal Farm"]]}
The following examples show how to map source data and target table.
// Specify fields from the target table to be matched with fields from the source JSON array by position.
// Positional matching is independent of the presence of a header information in the JSON content.
create.loadInto(BOOK)
.loadJSON(inputstream, encoding)
.fields(BOOK.ID, BOOK.AUTHOR_ID, BOOK.TITLE)
.execute();
// Use "null" field placeholders to ignore source columns by position.
create.loadInto(BOOK)
.loadJSON(inputstream, encoding)
.fields(BOOK.ID, null, BOOK.TITLE)
.execute();
// Match target fields with source fields by "corresponding" name.
// This assumes that JSON content contains header information as exported by jOOQ
create.loadInto(BOOK)
.loadJSON(inputstream, encoding)
.fieldsCorresponding()
.execute();
No other, JSON-specific options are currently available.
Feedback
Do you have any feedback about this page? We'd love to hear it!