Path (Integer)
The Path (Integer) node in Magick allows you to extract an integer value from a nested object using a dot-notated path string. This is useful when you need to retrieve a specific numeric property from a complex data structure.Inputs
-
pathToSearch(string, required): The dot-notated path string specifying the location of the integer value to extract from the input object. For example,"person.age"would retrieve theageproperty from thepersonobject. -
obj(object, required): The input object from which to extract the integer value.
Outputs
result(integer): The extracted integer value from the specified path in the input object. If the path is not found or the value is not an integer, the output will beundefined.
Configuration
This node has no additional configuration options.Usage
-
Connect an object to the
objinput of the Path (Integer) node. This is the object from which you want to extract an integer value. -
Set the
pathToSearchinput to a dot-notated string representing the path to the desired integer value within the input object. -
The extracted integer value will be available at the
resultoutput. You can then connect this output to other nodes in your spell as needed.
Example
Suppose you have an object representing a person with the following structure:age value from this object, you would:
- Connect the person object to the
objinput of the Path (Integer) node. - Set the
pathToSearchinput to"age". - The
resultoutput will contain the integer value30.
zip value from the nested address object, you would:
- Connect the person object to the
objinput of the Path (Integer) node. - Set the
pathToSearchinput to"address.zip". - The
resultoutput will contain the integer value12345.
Best Practices
- Make sure the
pathToSearchstring correctly matches the structure of your input object. Double-check the property names and nesting. - If the specified path doesn’t exist in the input object, the
resultoutput will beundefined. Handle this case appropriately in your spell’s logic.
Common Issues
- If the value at the specified path is not an integer, the
resultoutput will beundefined. Ensure that the path points to an integer value. - Be careful with the casing and spelling of property names in the
pathToSearchstring. JavaScript is case-sensitive, so"age"and"Age"are considered different properties.
