When loading a JSON export like:
jooq.loadInto(table)
.loadJSON(...)
.fields(field1, ..., fieldsN)
.execute();
you need to specify the fields even if the JSON already contains the field information.
This seems unnecessary and brittle.
I made a proof of concept change to jOOQ which seems to work, at least for my test cases.
I added LoaderJSONOptionsStep<R> fieldsFromJSON() to LoaderJSONStep
and an implementation to LoaderImpl that only sets a flag fieldsFromJSON:
@Override
public final LoaderImpl<R> fieldsFromJSON() {
this.fieldsFromJSON = true;
return this;
}
The only change needed to LoaderImpl.executeJSON() is to set fields to source if the new fieldsFromJSON flag is set:
private void executeJSON() throws IOException {
...
source = r.fields(); // old
if(this.fieldsFromJSON) // new
fields = source; // new
...
}
The new JSON load looks like this:
jooq.loadInto(table)
.loadJSON(...)
.fieldsFromJSON()
.execute();
Please consider adding this feature to jOOQ.