A collection of custom nodes for ComfyUI to manipulate and process JSON data.
为ComfyUI提供的一套JSON数据处理节点集合。
- Parse and extract JSON data
- Random value selection
- JSON object and array iteration
- JSON merging and modification
- JSON generation and formatting
- Key checking and length calculation
- Go to your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/
- Clone the repository:
git clone [email protected]:Q-Bug4/Comfyui-Json-Nodes.git
- Restart ComfyUI or reload custom nodes.
- Inputs:
json_string
: JSON stringpath
: Data path (optional)
- Outputs:
parsed_data
: Parsed JSON or specific valuearray_size
: Size if result is array
- Inputs:
json_input
: JSON stringmax_depth
: Maximum depth for random selection
- Outputs:
random_value
: Randomly selected value
- Inputs:
json_input
: JSON objectindex
: Current indexmode
: Iteration mode (fixed/incr/decr)
- Outputs:
key
: Current keyvalue
: Current valuecurrent_index
: Current positiontotal_items
: Total number of items
- Inputs:
json_input
: JSON arrayindex
: Current indexmode
: Iteration mode (fixed/incr/decr)
- Outputs:
item
: Current itemcurrent_index
: Current positiontotal_items
: Total number of items
- Inputs:
json_input_1
: First JSONjson_input_2
: Second JSONmerge_strategy
: Override/Preserve/Concat
- Outputs:
merged_json
: Combined JSON result
- Inputs:
json_input
: JSON to modifypath
: Path to modifynew_value
: New value
- Outputs:
modified_json
: Updated JSON
- Inputs:
key_value_pairs
: Key-value pairsis_array
: Generate array instead of object
- Outputs:
generated_json
: New JSON structure
- Inputs:
json_input
: JSON input
- Outputs:
length
: Number of items
- Inputs:
json_input
: JSON objectkey
: Key to check
- Outputs:
exists
: Boolean resultvalue
: Value if exists
- Inputs:
json_input
: JSON inputindent
: Indentation spacessort_keys
: Sort keys alphabetically
- Outputs:
json_string
: Formatted JSON string
- Nested objects:
object.nestedObject.property
- Array elements:
array[0]
orarray.0
- Complex structures:
object.array[2].property
# Input JSON
{
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
# Using Array Iterator with mode="incr"
# Will output each user object in sequence
# First input
{"name": "John", "age": 30}
# Second input
{"age": 31, "city": "New York"}
# Result with strategy="override"
{"name": "John", "age": 31, "city": "New York"}
# Input JSON
{
"colors": ["red", "blue", "green"],
"sizes": {"S": 10, "M": 20, "L": 30}
}
# Random value might return any color or size value
ValueError is raised for:
- Invalid JSON strings
- Invalid paths or keys
- Type mismatches
- Array index out of bounds
Improvements are welcome! Steps:
- Fork the repository
- Create a new branch
- Make changes
- Push to your fork
- Submit a Pull Request
MIT License. See LICENSE file for details.