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>();
88 table.pins_col = fetchOrDefault<std::string>( entry,
"pins" );
92 std::erase(
table.name,
'/' );
94 if( entry.contains(
"properties" ) && entry[
"properties"].is_object() )
96 const nlohmann::json& propJson = entry[
"properties"];
98 table.properties.description =
99 fetchOrDefault<std::string>( propJson,
"description" );
101 table.properties.footprint_filters =
102 fetchOrDefault<std::string>( propJson,
"footprint_filters" );
104 table.properties.keywords =
105 fetchOrDefault<std::string>( propJson,
"keywords" );
107 table.properties.exclude_from_bom =
108 fetchOrDefault<std::string>( propJson,
"exclude_from_bom" );
110 table.properties.exclude_from_board =
111 fetchOrDefault<std::string>( propJson,
"exclude_from_board" );
113 table.properties.exclude_from_sim =
114 fetchOrDefault<std::string>( propJson,
"exclude_from_sim" );
117 if( entry.contains(
"fields" ) && entry[
"fields"].is_array() )
119 for(
const nlohmann::json& fieldJson : entry[
"fields"] )
121 if( fieldJson.empty() || !fieldJson.is_object() )
125 fetchOrDefault<std::string>( fieldJson,
"column" ),
126 fetchOrDefault<std::string>( fieldJson,
"name" ),
127 fetchOrDefault<bool>( fieldJson,
"visible_on_add" ),
128 fetchOrDefault<bool>( fieldJson,
"visible_in_chooser" ),
129 fetchOrDefault<bool>( fieldJson,
"show_name" ),
130 fetchOrDefault<bool>( fieldJson,
"inherit_properties" ) ) );
134 m_Tables.emplace_back( std::move(
table ) );
139 m_params.emplace_back(
new PARAM<int>(
"cache.max_size", &m_Cache.max_size, 256 ) );
141 m_params.emplace_back(
new PARAM<int>(
"cache.max_age", &m_Cache.max_age, 10 ) );
143 m_params.emplace_back(
new PARAM<bool>(
"globally_unique_keys", &m_GloballyUniqueKeys,
false ) );
145 registerMigration( 0, 1,
153 if( !Contains(
"libraries" ) || !At(
"libraries" ).is_array() )
156 for( nlohmann::json&
library : At(
"libraries" ) )
158 if( !
library.contains(
"fields" ) )
161 for(
const nlohmann::json& field :
library[
"fields"] )
163 if( !field.contains(
"name" ) || !field.contains(
"column" ) )
166 std::string
name = field[
"name"].get<std::string>();
167 std::string col = field[
"column"].get<std::string>();
169 if(
name ==
"ki_description" )
170 library[
"properties"][
"description"] = col;
171 else if(
name ==
"ki_fp_filters" )
172 library[
"properties"][
"footprint_filters"] = col;