Mie Loop State Set ๐
Building a JSON state blob without touching loop_ctx
- state_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
_jsonfield is actually valid JSON for the type you want -5not"5"for a number,truenot"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. Validatebase_state_jsonon 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'sstate_jsonoutput as the nextbase_state_json.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| base_state_jsonopt | STRING | {} | โ |
| key1opt | STRING | โ | |
| value1_jsonopt | STRING | โ | |
| key2opt | STRING | โ | |
| value2_jsonopt | STRING | โ | |
| key3opt | STRING | โ | |
| value3_jsonopt | STRING | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| state_json | STRING | โ |