[SSN] JSON Get Value As
Cast a JSON value to bool, int, float, and string at once
- as_bool
- as_int
- as_float
- as_string
[SSN] JSON Get Value As takes a single JSON value as text and hands you four interpretations of it on four sockets: as_bool, as_int, as_float, and as_string. One input, four typed outputs, all ready to plug into whatever typed socket needs them.
The killer feature is as_string, because it's the answer to a question you'll ask within ten minutes of using this pack's other JSON nodes: "why does my value have quotes around it?" SsnJSONGetKeyValue and SsnJSONGetIndexValue both hand back json.dumps output, so strings come out as "green" - quotes and all. Run that through this node and as_string gives you bare green. It's the quote-stripper the rest of the pack implicitly assumes you'll have.
The casting logic is genuinely thought-through. For a parsed JSON value, as_bool is sensible (false for false, "", and "0", true for most non-empty strings and nonzero numbers), as_int truncates floats, as_float promotes ints, and as_string strips quotes. If the input isn't valid JSON at all - say the bare word hello - it falls back to treating your raw text as a string and does its best: int 0, float 0.0, bool true (it's non-empty and not "false"), string "hello". The fallback is forgiving in the way the whole pack is forgiving: quiet zeros and false rather than loud crashes. And because bare numbers are valid JSON, an input of 3 parses cleanly and gives you int 3, float 3.0, bool true.
Where it sits in a workflow: right after a Get Key Value or Get Index Value node, converting a single extracted value into the exact type a downstream widget wants. If your graph is pulling a seed, a boolean flag, or a filename out of a config blob, this is the terminal node that makes the text usable. It's also handy as a general "string to typed" converter even without the JSON pipeline, since its fallback path handles plain text.
The honest caveat: for objects and arrays the as_int/as_float outputs are just 0 and as_bool is false - this node is built for scalars, not nested structures. Keep it to primitives and it never disappoints.
Install
Part of smn_support_nodes by SummonTheCat. ComfyUI Manager → search smn_support_nodes → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/SummonTheCat/smn_support_nodes
Restart required. Dependencies (opencv-python, imageio-ffmpeg) auto-install; no models to download.
Troubleshooting
The traps are the quiet defaults: give it an object or array and the numeric outputs silently become 0, and a genuinely unparseable value goes to as_bool=false, not an error. If a downstream boolean is false when you expected true, double-check what string actually arrived - "False" with a capital F parses as JSON string "False", and the string-falsiness check treats it as truthy (only lowercase "false" is falsy). Watch that case-sensitivity if you're feeding it hand-typed booleans.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| json_value | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| as_bool | BOOL | — |
| as_int | INT | — |
| as_float | FLOAT | — |
| as_string | STRING | — |