64 [&]() -> nlohmann::json
69 [&](
const nlohmann::json aObj )
73 if( !aObj.is_array() )
76 for(
const nlohmann::json& entry : aObj )
78 if( entry.empty() || !entry.is_object() )
83 table.name = entry[
"name"].get<std::string>();
84 table.table = entry[
"table"].get<std::string>();
85 table.key_col = entry[
"key"].get<std::string>();
86 table.symbols_col = entry[
"symbols"].get<std::string>();
87 table.footprints_col = entry[
"footprints"].get<std::string>();
91 std::erase(
table.name,
'/' );
93 if( entry.contains(
"properties" ) && entry[
"properties"].is_object() )
95 const nlohmann::json& propJson = entry[
"properties"];
97 table.properties.description =
98 fetchOrDefault<std::string>( propJson,
"description" );
100 table.properties.footprint_filters =
101 fetchOrDefault<std::string>( propJson,
"footprint_filters" );
103 table.properties.keywords =
104 fetchOrDefault<std::string>( propJson,
"keywords" );
106 table.properties.exclude_from_bom =
107 fetchOrDefault<std::string>( propJson,
"exclude_from_bom" );
109 table.properties.exclude_from_board =
110 fetchOrDefault<std::string>( propJson,
"exclude_from_board" );
112 table.properties.exclude_from_sim =
113 fetchOrDefault<std::string>( propJson,
"exclude_from_sim" );
116 if( entry.contains(
"fields" ) && entry[
"fields"].is_array() )
118 for(
const nlohmann::json& fieldJson : entry[
"fields"] )
120 if( fieldJson.empty() || !fieldJson.is_object() )
124 fetchOrDefault<std::string>( fieldJson,
"column" ),
125 fetchOrDefault<std::string>( fieldJson,
"name" ),
126 fetchOrDefault<bool>( fieldJson,
"visible_on_add" ),
127 fetchOrDefault<bool>( fieldJson,
"visible_in_chooser" ),
128 fetchOrDefault<bool>( fieldJson,
"show_name" ),
129 fetchOrDefault<bool>( fieldJson,
"inherit_properties" ) ) );
133 m_Tables.emplace_back( std::move(
table ) );
138 m_params.emplace_back(
new PARAM<int>(
"cache.max_size", &m_Cache.max_size, 256 ) );
140 m_params.emplace_back(
new PARAM<int>(
"cache.max_age", &m_Cache.max_age, 10 ) );
142 m_params.emplace_back(
new PARAM<bool>(
"globally_unique_keys", &m_GloballyUniqueKeys,
false ) );
144 registerMigration( 0, 1,
152 if( !Contains(
"libraries" ) || !At(
"libraries" ).is_array() )
155 for( nlohmann::json&
library : At(
"libraries" ) )
157 if( !
library.contains(
"fields" ) )
160 for(
const nlohmann::json& field :
library[
"fields"] )
162 if( !field.contains(
"name" ) || !field.contains(
"column" ) )
165 std::string
name = field[
"name"].get<std::string>();
166 std::string col = field[
"column"].get<std::string>();
168 if(
name ==
"ki_description" )
169 library[
"properties"][
"description"] = col;
170 else if(
name ==
"ki_fp_filters" )
171 library[
"properties"][
"footprint_filters"] = col;