Nodes/Strata-T8/Strata JSON 提取 / Extract
ComfyUI Node

Strata JSON 提取 / Extract

Get one field out of JSON without a regex duct-tape job

By T8mars·Created 21 days ago·Updated 10 days ago· 20
Strata JSON 提取 / Extract
    • value
    • items
    • text_list
    ◄json_text—►
    ◄pointer/shots►
    ◄item_fieldprompt►
    ◄expected_type▾►

    Once you've got a validated document out of StrataT8Structured, you need pieces of it: the prompt for shot three, the list of prompts for the whole board, that one camera string. Regex on JSON is how people lose an afternoon. This node takes a JSON Pointer and returns exactly what's at that path.

    How it works

    You give it JSON text, a pointer, optionally a field name to pull out of every item, and an expected type. It resolves the pointer against the parsed document and hands back the value.

    The pointer is standard JSON Pointer syntax, and the pack is pedantic about it in the useful way:

    • It must start with / (/shots/0/prompt), or be empty - empty returns the whole document.
    • ~1 means / and ~0 means ~ if a key contains those characters.
    • Array indices must be plain decimal with no leading zeros. /shots/00 is an error, not a shrug.
    • A missing field gives you "JSON Pointer does not identify an existing field" - an error you can act on, instead of an empty string flowing into your encoder.
    • Trying to descend into a scalar (/shots/0/prompt/extra) is an error too.

    json_text is a force-input. You cannot type JSON into the widget; you have to wire it from a node. That's deliberate - it's meant to sit downstream of Structured, Vision or Video Analyze.

    The two fields that do the work

    item_field (default prompt) is how you handle lists. If the pointer resolves to an array, the node walks the items; with item_field set, every item must be an object containing that key, or it errors with "Every list item must contain the requested item field." That strictness is the point: if one shot in your storyboard came back missing its prompt, you find out here rather than generating four images and wondering why the third one is a picture of nothing. Clear the field and you get the raw items instead.

    expected_type - any, string, number, array, object, boolean. This is a type gate. Ask for number and get a string (models love writing "duration": "5"), and you get an error. Note that booleans are explicitly not numbers here, unlike in Python.

    Outputs

    • value - the resolved thing as text. Objects and arrays come back re-serialised as JSON, scalars come back as themselves.
    • items - a native STRING list: one entry per array element after item_field extraction. Downstream nodes run once per item, so Extract → CLIP Text Encode → KSampler gives you one image per shot without a loop node.
    • text_list - the same strings as one STRATA_TEXT_LIST, for feeding to StrataT8Batch.

    Which to use is the standard plumbing decision: a native STRING list fans out and executes downstream node-per-item; the STRATA_TEXT_LIST carries the batch as one object so a single node can process it (the KB's plumbing notes frames this as the value-fan-out pattern).

    Install

    Manager → search Strata-T8 (strata-t8, t8star), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/T8mars/Comfyui-Strata-T8.git
    python -m pip install -r Comfyui-Strata-T8/requirements.txt
    

    Only jsonschema gets added, and it's for the sibling nodes - this one is pure Python. Restart after installing. You still need a profile saved in the Strata-T8 sidebar plus a Connection node upstream of whatever produced your JSON; Extract itself touches no service, no GPU and no network, so you can happily test it by wiring it under a Text node carrying a hand-written JSON sample.

    Where people get burned

    Hand-fed JSON with duplicate keys is rejected. The parser behind this refuses duplicate members rather than silently keeping the last one. If you're pasting sample JSON to debug, check it.

    The pointer is case-sensitive and unforgiving. /Shots/0/prompt fails. If you changed a schema field name, update the pointer here too - this node has no idea what your schema says.

    Empty item_field is not the same as any. Clearing it returns whole objects (as JSON text), which is right when you want the item but wrong when you wanted one field from it.

    Wiring items into a sampler gives you one run per item. That's usually what you want, but if you also set a batch size on the sampler you'll get the multiplication you didn't ask for.

    CategoryStrata-T8

    Inputs (4)

    NameTypeDefaultDescription
    json_textSTRING—
    pointerSTRING/shots—
    item_fieldSTRINGprompt—
    expected_typeCOMBO6 options: any, string, number, array, object, boolean

    Outputs (3)

    NameTypeDescription
    valueSTRING—
    itemsSTRING—
    text_listSTRATA_TEXT_LIST—