Download

fill_data_table_from_json_string calls CSV parser instead of JSON parser

using unreal.DataTableFunctionLibrary

In found out that if I pass JSON data to the fill_data_table_from_json_string function, it will respond with an error coming from the CSV parser.

Tried passing it a CSV string and it worked. So it looks like the there is bug there.

We have the same problem here.

To reproduce the issue open a project in unreal and execute python script similar to this one:

asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
data_table_factory = unreal.DataTableFactory()
data_table_factory.struct = unreal.MaterialSubstitutionDataTable().static_struct()
table_asset = asset_tools.create_asset(asset_name="substitution_data_table",
                                        package_path="/Game/what/ever/folder/",
                                        asset_class=unreal.DataTable,
                                        factory=data_table_factory)
json_string = open(r"c:\path\to\some\file.json").read()
unreal.DataTableFunctionLibrary.fill_data_table_from_json_string(table_asset, json_string)

You should get error message similar to this one:

The interesting thing is, that if I try to import the json file manually via UI, then the script runs without problems. So some variable or property is probably changed during Json data import. May be it is possible to set this variable to the correct value just before the ‘fill_data_table_from_json_string’ is called?

Another idea would be to set the value of the source file field to the desired json file. Does anyone know how it can be done with python?

Best regards,
AK