68 [&]() -> nlohmann::json
73 [&](
const nlohmann::json aObj )
77 if( !aObj.is_array() )
80 for(
const nlohmann::json& entry : aObj )
82 if( entry.empty() || !entry.is_object() )
87 table.name = entry[
"name"].get<std::string>();
88 table.table = entry[
"table"].get<std::string>();
89 table.key_col = entry[
"key"].get<std::string>();
90 table.symbols_col = entry[
"symbols"].get<std::string>();
91 table.footprints_col = entry[
"footprints"].get<std::string>();
95 std::erase(
table.name,
'/' );
97 if( entry.contains(
"properties" ) && entry[
"properties"].is_object() )
99 const nlohmann::json& propJson = entry[
"properties"];
101 table.properties.description =
102 fetchOrDefault<std::string>( propJson,
"description" );
104 table.properties.footprint_filters =
105 fetchOrDefault<std::string>( propJson,
"footprint_filters" );
107 table.properties.keywords =
108 fetchOrDefault<std::string>( propJson,
"keywords" );
110 table.properties.exclude_from_bom =
111 fetchOrDefault<std::string>( propJson,
"exclude_from_bom" );
113 table.properties.exclude_from_board =
114 fetchOrDefault<std::string>( propJson,
"exclude_from_board" );
116 table.properties.exclude_from_sim =
117 fetchOrDefault<std::string>( propJson,
"exclude_from_sim" );
120 if( entry.contains(
"fields" ) && entry[
"fields"].is_array() )
122 for(
const nlohmann::json& fieldJson : entry[
"fields"] )
124 if( fieldJson.empty() || !fieldJson.is_object() )
128 fetchOrDefault<std::string>( fieldJson,
"column" ),
129 fetchOrDefault<std::string>( fieldJson,
"name" ),
130 fetchOrDefault<bool>( fieldJson,
"visible_on_add" ),
131 fetchOrDefault<bool>( fieldJson,
"visible_in_chooser" ),
132 fetchOrDefault<bool>( fieldJson,
"show_name" ),
133 fetchOrDefault<bool>( fieldJson,
"inherit_properties" ) ) );
137 m_Tables.emplace_back( std::move(
table ) );
142 m_params.emplace_back(
new PARAM<int>(
"cache.max_size", &m_Cache.max_size, 256 ) );
144 m_params.emplace_back(
new PARAM<int>(
"cache.max_age", &m_Cache.max_age, 10 ) );
146 registerMigration( 0, 1,
154 if( !Contains(
"libraries" ) || !At(
"libraries" ).is_array() )
157 for( nlohmann::json&
library : At(
"libraries" ) )
159 if( !
library.contains(
"fields" ) )
162 for(
const nlohmann::json& field :
library[
"fields"] )
164 if( !field.contains(
"name" ) || !field.contains(
"column" ) )
167 std::string
name = field[
"name"].get<std::string>();
168 std::string col = field[
"column"].get<std::string>();
170 if(
name ==
"ki_description" )
171 library[
"properties"][
"description"] = col;
172 else if(
name ==
"ki_fp_filters" )
173 library[
"properties"][
"footprint_filters"] = col;