Nodes/smn_support_nodes/[SSN] JSON Get Index Value
ComfyUI Node

[SSN] JSON Get Index Value

Index into a JSON array by position — the sibling of the key getter

By SummonTheCat·Created about a year ago·Updated about a year ago· 0
[SSN] JSON Get Index Value
    • value
    ◄json_string[]►
    ◄index0►

    [SSN] JSON Get Index Value pulls one element out of a JSON array by position. Feed it a JSON array as a string plus an index, and you get back the element at that spot - ["red", "green", "blue"] with index 1 returns "green". If your data is an object of named fields, you want its sibling SsnJSONGetKeyValue instead; this one is for lists.

    It's the natural companion to SsnInputJSON for the "config in one box" workflow, with the twist that arrays don't have meaningful names - you're saying "give me the third item," not "give me the item called X." That makes it useful for things like a list of seeds, a list of checkpoint names, or any response from an API or LLM node that arrives as an ordered list and needs one position wired somewhere. Combine it with a changing index from an input node and you've got a poor-man's array indexer - iterate a list without touching the JSON itself.

    Indexing is zero-based and the node is defensive by design: if the JSON doesn't parse, isn't an array, or the index is out of bounds, it returns an empty string rather than crashing the graph. That's friendly, but it's the same quiet-failure trade as the pack's other JSON nodes - an out-of-range index silently becomes "" and whatever consumes it gets nothing. The output is json.dumps of the element, so strings come back quoted ("green" with quote characters); run it through SsnJSONGetValueAs if you need bare text.

    One nice detail: unlike the key-value sibling, this node's json_string input is multiline, so you can paste a pretty-printed array and it parses fine. Small inconsistency in the pack, but convenient for exactly this node.

    Install

    Part of smn_support_nodes by SummonTheCat. ComfyUI Manager → search smn_support_nodes → Install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/SummonTheCat/smn_support_nodes
    

    Restart required. Dependencies (opencv-python, imageio-ffmpeg) auto-install; no models to download.

    Troubleshooting

    The classic trip-ups: indexing from 1 when the node is zero-based (index 3 on a 3-item list is out of bounds → ""), and forgetting the element comes back quoted if it's a string. Also remember this node expects an array - feed it a JSON object and every index comes back empty. If your "array" is actually a comma-separated plain string, that's not JSON; wrap it in brackets first or parse it upstream.

    CategoryJSON

    Inputs (2)

    NameTypeDefaultDescription
    json_stringSTRING[]—
    indexINT00–2147483647—

    Outputs (1)

    NameTypeDescription
    valueSTRING—