Nodes
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 theage
property from theperson
object. -
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
obj
input of the Path (Integer) node. This is the object from which you want to extract an integer value. -
Set the
pathToSearch
input 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
result
output. 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:
To extract the age
value from this object, you would:
- Connect the person object to the
obj
input of the Path (Integer) node. - Set the
pathToSearch
input to"age"
. - The
result
output will contain the integer value30
.
To extract the zip
value from the nested address
object, you would:
- Connect the person object to the
obj
input of the Path (Integer) node. - Set the
pathToSearch
input to"address.zip"
. - The
result
output will contain the integer value12345
.
Best Practices#
- Make sure the
pathToSearch
string 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
result
output 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
result
output will beundefined
. Ensure that the path points to an integer value. - Be careful with the casing and spelling of property names in the
pathToSearch
string. JavaScript is case-sensitive, so"age"
and"Age"
are considered different properties.