Nodes/ComfyUI_MieNodes/Mie Loop State Set ๐Ÿ‘
ComfyUI Node

Mie Loop State Set ๐Ÿ‘

Building a JSON state blob without touching loop_ctx

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
Mie Loop State Set ๐Ÿ‘
    • state_json
    โ—„base_state_json{}โ–บ
    โ—„key1โ–บ
    โ—„value1_jsonโ–บ
    โ—„key2โ–บ
    โ—„value2_jsonโ–บ
    โ—„key3โ–บ
    โ—„value3_jsonโ–บ

    This one looks like it belongs with the typed Get/Set family (Bool, Float, Image, Int, String) because it lives in the same Loop category and shares the "State Set" name, but it's actually a different tool. Every node in that other family reads or writes a value on a MIE_LOOP_CTX object. This node doesn't touch MIE_LOOP_CTX at all - every one of its inputs is optional, and it works entirely in plain JSON strings.

    What it actually does. You give it a base_state_json (a JSON object as text, default "{}") and up to three key/value pairs (key1/value1_json, key2/value2_json, key3/value3_json, all optional strings). It merges those pairs onto the base object and hands you back a single state_json string - the base plus whatever you added, serialized as one JSON blob.

    Read against the rest of the pack, the obvious use is building the starting state for a loop before it begins - composing an initial JSON object by hand (a seed value, a starting counter, a config flag) that you then feed into whichever node in this pack's Loop category expects a JSON string to kick things off. It's just as usable standalone, though: anywhere you want to assemble a small JSON object from a handful of key/value pairs without writing a JSON string by hand or reaching for a scripting node, this does the job - a compact config block, a log entry, a parameter bundle to pass to an LLM prompt.

    Inputs, all optional.

    • base_state_json (default "{}") - the object you're adding to. Leave it at the default to start from scratch.
    • key1 / value1_json, key2 / value2_json, key3 / value3_json - each pair is a key name plus its value, and the value is expected as a JSON-encoded string (so a plain number goes in as "5", a string as "\"hello\"", a bool as "true") rather than a raw Python value. That "_json" suffix on the value fields is the tell - get the quoting wrong and you'll end up with a string where you wanted a number.

    Output: state_json (STRING) - the merged object as one JSON string, ready to feed downstream.

    Installing. ComfyUI Manager: search ComfyUI_MieNodes and install. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/MieMieeeee/ComfyUI-MieNodes, restart ComfyUI. No models involved.

    Worth being upfront about: this node, like the rest of the Loop category, gets zero mentions in the README - no node table, no example workflow, and nothing that confirms exactly which downstream node is meant to consume state_json. The read above (that it's for seeding a loop's initial state) is inferred from its position in the Loop category and its all-optional, JSON-merging shape; it's a solid guess, not confirmed behavior.

    Troubleshooting.

    • Merged JSON has your value as a string when you wanted a number or bool. Check your _json field is actually valid JSON for the type you want - 5 not "5" for a number, true not "true" for a bool. Since these are plain STRING widgets, it's easy to type the value the way you'd type it anywhere else and get a quoted string back instead.
    • Output looks like invalid JSON, or a downstream node errors trying to parse it. Malformed base_state_json (not actually a JSON object) or a key/value pair with unescaped quotes inside the JSON string will break the merge. Validate base_state_json on its own first if you're building it from another string source.
    • Only some of your key/value pairs show up. Remember only three slots exist here (key1โ€“key3); if you need more fields than that, chain a second Mie Loop State Set node off this one's state_json output as the next base_state_json.
    Category๐Ÿ‘ MieNodes/๐Ÿ‘ Loop

    Inputs (7)

    NameTypeDefaultDescription
    base_state_jsonoptSTRING{}โ€”
    key1optSTRINGโ€”
    value1_jsonoptSTRINGโ€”
    key2optSTRINGโ€”
    value2_jsonoptSTRINGโ€”
    key3optSTRINGโ€”
    value3_jsonoptSTRINGโ€”

    Outputs (1)

    NameTypeDescription
    state_jsonSTRINGโ€”