GhJSON includes fuzzy name resolution for Grasshopper component and parameter names. This is useful when working with AI-generated GhJSON where the AI may use informal names, abbreviations, or slight misspellings.
Name resolution uses a multi-strategy approach, applied in order:
- Alias lookup — A built-in dictionary maps common shorthand names to canonical Grasshopper names (e.g.,
"slider"→"Number Slider","pt"→"Point") - Exact match — Case-insensitive exact string comparison
- Normalized match — Strips spaces, underscores, and hyphens before comparing (e.g.,
"number_slider"matches"Number Slider") - Prefix match — Returns a candidate if the input is a unique prefix
- Contains match — Returns the shortest candidate containing the input
- Levenshtein distance — Tolerates small typos (configurable max distance)
using GhJSON.Core;
// Alias-only resolution (no fuzzy matching against a candidate list)
string? name = GhJson.ResolveComponentAlias("slider");
// Returns: "Number Slider"
// Full resolution with fuzzy matching against known names
var knownNames = new[] { "Addition", "Subtraction", "Multiplication", "Division" };
string? resolved = GhJson.ResolveComponentName("Addtion", knownNames);
// Returns: "Addition" (Levenshtein distance 1)| Alias | Canonical Name |
|---|---|
slider, numberslider, numslider |
Number Slider |
panel |
Panel |
pt, point |
Point |
crv, curve |
Curve |
bool, boolean |
Boolean |
toggle, booleantoggle |
Boolean Toggle |
add, plus, addition |
Addition |
sub, minus, subtraction |
Subtraction |
mul, multiply, multiplication |
Multiplication |
div, divide, division |
Division |
cube, box |
Box |
rect, rectangle |
Rectangle |
circ, circle |
Circle |
cyl, cylinder |
Cylinder |
xyz, constructpoint, ptxyz |
Construct Point |
vec, vector, vectorxyz |
Vector XYZ |
loft |
Loft |
series |
Series |
range |
Range |
move |
Move |
rotate |
Rotate |
scale |
Scale |
See ComponentNameResolver.cs for the full list.
using GhJSON.Core;
// Alias-only resolution
string? param = GhJson.ResolveParameterAlias("r");
// Returns: "Radius"
// Full resolution with fuzzy matching
var knownParams = new[] { "Radius", "Plane", "Point" };
string? resolved = GhJson.ResolveParameterName("Radus", knownParams);
// Returns: "Radius" (Levenshtein distance 1)| Alias | Canonical Name |
|---|---|
r, radius |
Radius |
pt, point |
Point |
num, number |
Number |
geo, geometry |
Geometry |
crv, curve |
Curve |
srf, surface |
Surface |
dir, direction |
Direction |
vec, vector |
Vector |
a |
A |
b |
B |
result |
Result |
x, y, z |
X, Y, Z |
width |
X Size |
length |
Y Size |
height |
Z Size |
i, index |
Index |
See ParameterNameResolver.cs for the full list.
Name resolution is automatically applied as a fallback during deserialization:
- Component instantiation (
ComponentInstantiator): When a component name doesn't match any registered Grasshopper component exactly, fuzzy resolution is attempted before failing. - Connection wiring (
CanvasPlacer): When a parameter name in a connection endpoint doesn't match any parameter on the target component exactly, fuzzy resolution is attempted.
This means GhJSON documents with informal names like "slider" or slight typos like "Addtion" will still deserialize correctly when placed on the canvas via GhJsonGrasshopper.Put().