PettyPaintJsonReadArray
Grab the Nth element out of a JSON array
- STRING
JSON Read gives you values by key. This one gives you values by position. PettyPaintJsonReadArray takes a JSON array and an integer index and returns the element at that spot - element 0, element 3, element 7. It's the companion to PettyPaintJsonRead for everything array-shaped, and in the petty-paint pack that's a real workflow need: the app's project state is full of arrays - setups, prompts, loras - and picking one entry by number is how you select which one to work on.
The pack is the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines doodles through Stable Diffusion.
How it works
text is the JSON, expected to be an array. path is not a string here - it's an INT (0–100, default 0). The node parses the JSON, indexes into it with that integer, and returns the element as a string. That's the whole job: array plus index equals element. Feed it a JSON string, dial the index, get the entry out.
The integer-typed path is the giveaway of intent: you're meant to drive it with another value, not type a path by hand. That's why the index is forced-input - wire it to a counter node, a random picker, or a loop variable and you can walk through a whole JSON array programmatically.
The inputs and outputs
text- STRING; the JSON array to index into.path- INT (0–100); which element to pull.- Output:
STRING- the element at that index.
Installing it
Same pack, same install - ComfyUI Manager, search "petty-paint-comfyui-node":
cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node
Restart ComfyUI. Declared dependency is Flask==2.1.2; nothing to download.
Common issues
If you pass a JSON object instead of an array, indexing with an integer won't do what you expect - this node is strictly for arrays; objects are PettyPaintJsonRead's domain. Out-of-range indexes throw, so keep your index below the array length (the input caps at 100, which is generous but not infinite). And if you're pulling one entry out of a setups array, remember the index is zero-based - setup 1 is index 0.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| path | INT | 00–100 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |