master
Ondřej Hruška 4 years ago
commit 1be96a81a3
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 1
      .gitignore
  2. 11
      .idea/dashie-json-cleaner.iml
  3. 8
      .idea/modules.xml
  4. 6
      .idea/vcs.xml
  5. 117
      .idea/workspace.xml
  6. 85
      Cargo.lock
  7. 12
      Cargo.toml
  8. 643
      cleaned.json
  9. 1491
      src/categories.json
  10. 20
      src/main.rs

1
.gitignore vendored

@ -0,0 +1 @@
/target

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/dashie-json-cleaner.iml" filepath="$PROJECT_DIR$/.idea/dashie-json-cleaner.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated />
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="347ac394-0ad5-4cf8-9761-e820aa06b74f" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="FileColors">
<fileColor scope="Non-Project Files (Material Default)" color="2E3C43" />
<fileColor scope="Non-Project Files (Material Darker)" color="323232" />
<fileColor scope="Non-Project Files (Material Lighter)" color="eae8e8" />
<fileColor scope="Non-Project Files (Material Palenight)" color="2f2e43" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="7efyyuuv" />
</component>
<component name="ProjectId" id="1kCnbhHOO1kdzdJlamS78WTnV0i" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="cf.first.check.clang-format" value="false" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="settings.editor.selected.configurable" value="editor.preferences.gutterIcons" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src" />
</key>
</component>
<component name="RunManager">
<configuration name="Run" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="run --package dashie-json-cleaner --bin dashie-json-cleaner" />
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration default="true" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="channel" value="DEFAULT" />
<option name="command" value="run" />
<option name="allFeatures" value="false" />
<option name="emulateTerminal" value="false" />
<option name="backtrace" value="SHORT" />
<envs />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="/usr/bin" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="347ac394-0ad5-4cf8-9761-e820aa06b74f" name="Default Changelist" comment="" />
<created>1605213513593</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1605213513593</updated>
<workItem from="1605213514991" duration="506000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="WindowStateProjectService">
<state width="1870" height="476" key="GridCell.Tab.0.bottom" timestamp="1605213924711">
<screen x="0" y="32" width="1920" height="1168" />
</state>
<state width="1870" height="476" key="GridCell.Tab.0.bottom/0.32.1920.1168/1920.0.1600.1200@0.32.1920.1168" timestamp="1605213924711" />
<state width="1870" height="476" key="GridCell.Tab.0.center" timestamp="1605213924711">
<screen x="0" y="32" width="1920" height="1168" />
</state>
<state width="1870" height="476" key="GridCell.Tab.0.center/0.32.1920.1168/1920.0.1600.1200@0.32.1920.1168" timestamp="1605213924711" />
<state width="1870" height="476" key="GridCell.Tab.0.left" timestamp="1605213924711">
<screen x="0" y="32" width="1920" height="1168" />
</state>
<state width="1870" height="476" key="GridCell.Tab.0.left/0.32.1920.1168/1920.0.1600.1200@0.32.1920.1168" timestamp="1605213924711" />
<state width="1870" height="476" key="GridCell.Tab.0.right" timestamp="1605213924711">
<screen x="0" y="32" width="1920" height="1168" />
</state>
<state width="1870" height="476" key="GridCell.Tab.0.right/0.32.1920.1168/1920.0.1600.1200@0.32.1920.1168" timestamp="1605213924711" />
</component>
</project>

85
Cargo.lock generated

@ -0,0 +1,85 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "dashie-json-cleaner"
version = "0.1.0"
dependencies = [
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "itoa"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "serde"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
[[package]]
name = "serde_derive"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"

@ -0,0 +1,12 @@
[package]
name = "dashie-json-cleaner"
version = "0.1.0"
authors = ["Ondřej Hruška <ondra@ondrovo.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1.0.117"
serde_json = "1.0.59"
serde_derive = "1.0.117"

@ -0,0 +1,643 @@
{
"name": "Root Category",
"children": [
{
"name": "# Free Space",
"description": ""
},
{
"name": "1 Active Components",
"description": "",
"children": [
{
"name": "1 Semiconductors",
"description": "",
"children": [
{
"name": "1 Transistors",
"description": "",
"children": [
{
"name": "MOSFET",
"description": ""
},
{
"name": "NPN",
"description": ""
},
{
"name": "PNP",
"description": ""
}
]
},
{
"name": "2 Integrated Circuits",
"description": "",
"children": [
{
"name": "1 7400 series",
"description": "https://en.wikipedia.org/wiki/List_of_7400-series_integrated_circuits",
"children": [
{
"name": "1 Counters",
"description": ""
},
{
"name": "Z Others",
"description": ""
}
]
},
{
"name": "2 ADC, DAC",
"description": ""
},
{
"name": "3 Microcontrollers",
"description": ""
},
{
"name": "4 OpAmps",
"description": ""
},
{
"name": "5 Timers",
"description": ""
},
{
"name": "6 EPROM",
"description": ""
},
{
"name": "7 EEPROM",
"description": ""
},
{
"name": "8 Comparators",
"description": ""
},
{
"name": "9 MOSFET Drivers",
"description": ""
},
{
"name": "A Voltage Regulators / Controllers",
"description": ""
},
{
"name": "Z Others",
"description": ""
},
{
"name": "B FPGA",
"description": ""
},
{
"name": "C CPLD",
"description": ""
},
{
"name": "D PAL",
"description": ""
},
{
"name": "E GAL",
"description": ""
},
{
"name": "F RAM",
"description": "",
"children": [
{
"name": "SRAM",
"description": ""
},
{
"name": "DRAM",
"description": ""
}
]
},
{
"name": "G Buffer/Line driver",
"description": ""
},
{
"name": "H UART / Serial",
"description": ""
},
{
"name": "0 4000 series",
"description": "https://en.wikipedia.org/wiki/List_of_4000-series_integrated_circuits",
"children": [
{
"name": "Analog Switches",
"description": ""
}
]
}
]
},
{
"name": "3 Diodes",
"description": "",
"children": [
{
"name": "1 Universal",
"description": ""
},
{
"name": "2 Schottky",
"description": ""
},
{
"name": "3 Z Diodes",
"description": ""
},
{
"name": "4 Rectifiers and Rectifier Diodes",
"description": ""
}
]
},
{
"name": "4 Triacs",
"description": ""
},
{
"name": "5 Voltage References",
"description": ""
},
{
"name": "Thyristor",
"description": "",
"children": [
{
"name": "1 TRIACs",
"description": ""
},
{
"name": "2 SCR",
"description": ""
}
]
}
]
},
{
"name": "2 Optoelectronics",
"description": "",
"children": [
{
"name": "1 LED",
"description": "",
"children": [
{
"name": "Module",
"description": ""
},
{
"name": "SMD",
"description": ""
},
{
"name": "Standard",
"description": ""
}
]
},
{
"name": "2 LCD Displays",
"description": "",
"children": [
{
"name": "1 Text",
"description": ""
},
{
"name": "2 Graphics",
"description": ""
}
]
},
{
"name": "3 Octocouplers",
"description": ""
},
{
"name": "4 Others",
"description": ""
},
{
"name": "5 Optical Switches",
"description": ""
}
]
},
{
"name": "3 Others",
"description": "",
"children": [
{
"name": "Inverter",
"description": ""
}
]
}
]
},
{
"name": "2 Passive Components",
"description": "",
"children": [
{
"name": "1 Resistors",
"description": "",
"children": [
{
"name": "1 Metal Film 1%",
"description": ""
},
{
"name": "2 Carbon Film 5%",
"description": ""
},
{
"name": "3 Networks",
"description": ""
},
{
"name": "4 Power Resistors",
"description": ""
},
{
"name": "PTC",
"description": ""
}
]
},
{
"name": "2 Capacitors",
"description": "",
"children": [
{
"name": "1 Ceramic",
"description": ""
},
{
"name": "2 Electrolythic",
"description": ""
},
{
"name": "3 Film",
"description": ""
},
{
"name": "Styroflex",
"description": ""
},
{
"name": "Tantal",
"description": ""
}
]
},
{
"name": "3 Crystals, OSC, Filt",
"description": "",
"children": [
{
"name": "1 Crystals",
"description": ""
},
{
"name": "2 Oscillators",
"description": ""
},
{
"name": "3 Filters",
"description": ""
}
]
},
{
"name": "4 Potentiometers / Padders",
"description": "",
"children": [
{
"name": "1 Potentiometers",
"description": ""
},
{
"name": "2 Trimmer",
"description": "",
"children": [
{
"name": "1 10/25 Tirms precision",
"description": ""
},
{
"name": "2 Cermet",
"description": ""
},
{
"name": "3 Precision",
"description": ""
}
]
},
{
"name": "3 Slide Potentiometer",
"description": ""
},
{
"name": "4 Encoders",
"description": ""
}
]
},
{
"name": "8 Photoresistors / LDRs",
"description": ""
},
{
"name": "9 Varistor",
"description": ""
}
]
},
{
"name": "3 Electromechanical Parts",
"description": "",
"children": [
{
"name": "1 Connectors",
"description": "",
"children": [
{
"name": "1 IC Sockets",
"description": ""
},
{
"name": "2 PCB Connectors",
"description": "",
"children": [
{
"name": "1 Rectangular",
"description": "",
"children": [
{
"name": "1 Wire-to-Board",
"description": ""
},
{
"name": "2 USB",
"description": ""
},
{
"name": "3 D-Sub",
"description": ""
},
{
"name": "4 IDC Connectors and Box Headers",
"description": ""
},
{
"name": "5 Terminal Blocks",
"description": ""
},
{
"name": "6 Board to Board",
"description": ""
},
{
"name": "7 Pin Headers",
"description": ""
}
]
},
{
"name": "2 Round",
"description": ""
},
{
"name": "3 Audio",
"description": ""
},
{
"name": "4 Others",
"description": ""
},
{
"name": "5 WAGO",
"description": ""
},
{
"name": "6 Faston",
"description": ""
},
{
"name": "7 HF",
"description": ""
},
{
"name": "8 DC Power Jacks",
"description": ""
},
{
"name": "9 Lab Connectors",
"description": ""
}
]
}
]
},
{
"name": "2 Switches and Buttons",
"description": "",
"children": [
{
"name": "1 Switches",
"description": ""
},
{
"name": "2 Push Button",
"description": ""
},
{
"name": "3 Code Switches",
"description": ""
},
{
"name": "4 DIP Switches",
"description": ""
},
{
"name": "5 Accessories",
"description": ""
}
]
},
{
"name": "3 Relais",
"description": ""
},
{
"name": "4 Fuses",
"description": "",
"children": [
{
"name": "1 5*20",
"description": ""
},
{
"name": "2 6,3*32",
"description": ""
},
{
"name": "3 Blade Fuses",
"description": ""
}
]
},
{
"name": "5 Battery Holders",
"description": ""
},
{
"name": "6 Transformers",
"description": ""
},
{
"name": "7 Motors",
"description": "",
"children": [
{
"name": "1 DC",
"description": ""
},
{
"name": "2 Stepper",
"description": ""
},
{
"name": "3 Servo",
"description": ""
},
{
"name": "4 Brushless",
"description": ""
}
]
},
{
"name": "8 Selenoids",
"description": ""
}
]
},
{
"name": "4 Mechanical Parts",
"description": "",
"children": [
{
"name": "1 Mica Washers",
"description": ""
},
{
"name": "2 Cooling",
"description": ""
},
{
"name": "3 Screws",
"description": "",
"children": [
{
"name": "1 Auto",
"description": ""
},
{
"name": "2 Mx",
"description": ""
},
{
"name": "3 Imperial",
"description": ""
}
]
},
{
"name": "5 Nuts",
"description": ""
},
{
"name": "6 Pulleys",
"description": ""
},
{
"name": "7 Bearings",
"description": ""
},
{
"name": "8 Spacers",
"description": ""
},
{
"name": "9 Sliding things",
"description": ""
}
]
},
{
"name": "5 Cables",
"description": "",
"children": [
{
"name": "1 Spools",
"description": ""
},
{
"name": "2 Ribbon Cable",
"description": ""
}
]
},
{
"name": "6 Speakers and Buzzers",
"description": ""
},
{
"name": "V Modules",
"description": ""
},
{
"name": "W PC Stuff",
"description": ""
},
{
"name": "X PCB Material",
"description": ""
},
{
"name": "Y Other Stuff",
"description": ""
},
{
"name": "Z Projects",
"description": ""
},
{
"name": "U 3D Printing",
"description": ""
},
{
"name": "T Books",
"description": ""
},
{
"name": "# To test",
"description": ""
}
]
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,20 @@
#[macro_use] extern crate serde_json;
#[macro_use] extern crate serde_derive;
#[derive(Serialize,Deserialize,Debug,Clone)]
struct Node {
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Vec::is_empty")]
children: Vec<Node>,
}
fn main() {
let source = include_str!("categories.json");
let parsed : Node = serde_json::from_str(source).expect("parse");
println!("{}", serde_json::to_string_pretty(&parsed).expect("serialize"));
}
Loading…
Cancel
Save