CE-781 Update to work without a table specified (just getting field names from the json keys)

This commit is contained in:
2024-01-08 12:39:43 -06:00
parent a00d4f3cbd
commit 06259041f8
2 changed files with 38 additions and 5 deletions

View File

@ -103,13 +103,23 @@ public class JsonToQRecordAdapter
{
QRecord record = new QRecord();
for(QFieldMetaData field : table.getFields().values())
if(table == null)
{
String fieldSource = mapping == null ? field.getName() : String.valueOf(mapping.getFieldSource(field.getName()));
// todo - so if the mapping didn't say how to map this field, does that mean we should use the default name for the field?
if(jsonObject.has(fieldSource))
jsonObject.keys().forEachRemaining(key ->
{
record.setValue(field.getName(), (Serializable) jsonObject.get(fieldSource));
record.setValue(key, jsonObject.optString(key));
});
}
else
{
for(QFieldMetaData field : table.getFields().values())
{
String fieldSource = mapping == null ? field.getName() : String.valueOf(mapping.getFieldSource(field.getName()));
// todo - so if the mapping didn't say how to map this field, does that mean we should use the default name for the field?
if(jsonObject.has(fieldSource))
{
record.setValue(field.getName(), (Serializable) jsonObject.get(fieldSource));
}
}
}