ComfyUI Node

PettyPaintJsonMap

Pull a dotted path out of every element of a JSON list

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
PettyPaintJsonMap
    • data
    • STRING
    text
    path

    JsonRead gets one value from one JSON object. But the petty-paint pack's state files are full of lists of objects - an array of setups, each with a model, a prompt, a set of loras - and the question is usually "give me the model from every setup," not "give me one." PettyPaintJsonMap is the map function for that: it takes a JSON array and a dotted path, walks the path through every element, and hands you a list of the results. One call, whole column extracted.

    The pack is the ComfyUI-side integration for Petty Paint, Andrew Porter's web canvas that reimagines doodles through Stable Diffusion. When the app's JSON project file needs to be turned into graph inputs, this is the extraction node.

    How it works

    text is the JSON, expected to be an array. path is a dotted key path, same syntax as PettyPaintJsonRead - model or character_defaults.steps or loras.0.name. For each element in the array the node walks the path key by key and collects what it finds, so you get a result list of the same length as the input array. Elements missing a key just contribute whatever's left at their current level rather than erroring.

    The inputs and outputs

    • text - STRING; the JSON array.
    • path - STRING; the dotted path to pull from each element.
    • Outputs: data (STRING) - the mapped result list - plus a second STRING output. One honest caveat: the schema declares both outputs, but the shipped code returns a single result, and that mismatch can trip a "got 1, expected 2" error on some ComfyUI versions. If the node errors right after running, that's what you're looking at.

    A natural follow-up: map out a field like model, then use PettyPaintJsonReadArray with a wired index to walk the list, or hand the whole thing to the pack's PettyPaintLoRAStack if it's lora entries.

    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; no models, no heavy deps.

    Common issues

    The same JSON caveats as the rest of the family: invalid JSON throws, and this node expects an array - feed it an object and you'll get odd results. Out-of-range or missing keys are treated leniently, which is friendly for ragged data but means a typo in your path can silently produce a list of wrong or partial values. And if you need to transform each element rather than just extract a path - compute something, combine fields - that's what PettyPaintMap in the same pack is for (it runs a Python expression per element). For plain extraction, this is the boring, correct tool.

    CategoryPettyPaint

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    pathSTRING

    Outputs (2)

    NameTypeDescription
    dataSTRING
    STRINGSTRING