Files
DumasNodes/dumas_json_nodes.py
2026-07-21 10:43:24 +00:00

33 lines
787 B
Python

import json
class DumasJSONStringToObjectNode:
CATEGORY = "Dumas/JSON"
RETURN_TYPES = ("JSON",)
FUNCTION = "convert_string_to_json"
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"json_string": ("STRING", {"multiline": True}),
}
}
def convert_string_to_json(self, json_string):
try:
json_object = json.loads(json_string)
return (json_object,)
except json.JSONDecodeError as exc:
print(f"[DumasNodes] Error decoding JSON: {exc}")
return (None,)
NODE_CLASS_MAPPINGS = {
"DumasJSONStringToObject": DumasJSONStringToObjectNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"DumasJSONStringToObject": "Dumas JSON String to Object",
}