add code and readme.

This commit is contained in:
Holger Will
2024-08-15 18:39:47 +02:00
parent 7c8a86cd6e
commit 0fc0c21ad3
4 changed files with 96 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
import json
class JSONStringToObjectNode:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {"required": {"json_string": ("STRING", {"multiline": True})}}
RETURN_TYPES = ("JSON",)
FUNCTION = "convert_string_to_json"
def convert_string_to_json(self, json_string):
try:
json_object = json.loads(json_string)
return (json_object,)
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
return (None,)
NODE_CLASS_MAPPINGS = {
"JSONStringToObjectNode": JSONStringToObjectNode
}
NODE_DISPLAY_NAME_MAPPINGS = {
"JSONStringToObjectNode": "JSON String to Object"
}