Initial DumasNodes seed
This commit is contained in:
32
dumas_json_nodes.py
Normal file
32
dumas_json_nodes.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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",
|
||||
}
|
||||
Reference in New Issue
Block a user