Nodes/ComfyUI XAV JSON Nodes/XAV Set JSON Value
ComfyUI Node

XAV Set JSON Value

Editing your JSON is easy — just know everything you type becomes a string

By XAV-Games·Created 5 months ago·Updated 5 months ago· 2
XAV Set JSON Value
    • json_ref
    json_ref
    key
    value

    The edit node. You've got a json_ref pointing at some object or array, and this node pokes a value into it at a key. Three inputs: json_ref, key (a property name for dicts, or an index written as text like "0" for lists), and value - the thing to write. The output is the same json_ref back, because the node mutates the object in place and the handle stays valid. That's convenient: wire it once and the entire downstream chain sees the updated data.

    Now the headline gotcha, straight from the source: value is a STRING input, and it's stored as-is. Set a key to 5 and your JSON contains "5" - a string, not a number. There's no type dropdown, no int/float mode, no type-guessing. If you genuinely need a real number in the payload, you have two moves: convert on the way out with XAV JSON to Primitives (the file still stores "5", but downstream wires carry a real 5), or carry a number in from a loaded file via XAV Set JSON Value From Ref. This pack simply will not type a value you typed by hand. Accept it, and build around it.

    Second, dicts and lists behave differently, and it's worth knowing which one you're pointing at:

    • Dictobj[key] = value. Adds or overwrites the key. No bounds problems, and setting a brand-new key works fine.
    • List → the key is parsed as an index and only applied if it's in range. You can overwrite items[0], but you can't append and you can't grow the list past its current length.

    There's no push/append anywhere in this pack. If you need an array of a certain size, build it that size up front - create an empty array and fill each in-range index, or load one from a file - then overwrite as needed.

    Third: if the ref points at nothing, the node silently does nothing and returns the same ref. No error, no feedback. Pair that with XAV Navigate JSON's habit of returning None refs on missing keys and you can build a chain that appears to work while never writing a single value. Worth checking your navigates before you debug the set.

    Where you'll actually use this: nudging a config value, stamping a version string or tag into a manifest, injecting a prompt snippet into a template you're about to save. For anything that's going into a text encoder downstream, the string-ness is fine - it's only JSON-text output that cares about the type. And remember the persistence angle from the create node: refs live in a process-global cache that ComfyUI never clears, so edits accumulate until you restart or re-add the node. If values you "removed" keep coming back, that's why.

    Install is painless - this pack is pure Python stdlib, zero dependencies, no pip install, no models. ComfyUI Manager → Install Custom Nodes → search "ComfyUI XAV JSON Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/XAV-Games/ComfyUI-XAVJsonNodes
    

    Restart ComfyUI and all seven nodes are under Add Node → XAV/json.

    CategoryXAV/json

    Inputs (3)

    NameTypeDefaultDescription
    json_refSTRING
    keySTRING
    valueSTRING

    Outputs (1)

    NameTypeDescription
    json_refSTRING