Skip to content

Commit

Permalink
Update base.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jagenjo committed Oct 27, 2023
1 parent 3acdcee commit 015547d
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/nodes/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@
GraphInput.title = "Input";
GraphInput.desc = "Input of the graph";

GraphInput.prototype.onConfigure = function()
GraphInput.prototype.onConfigure = function()

{
this.updateType();
}
Expand Down Expand Up @@ -983,6 +984,48 @@

LiteGraph.registerNodeType("basic/file", ConstantFile);


//to store json objects
function JSONParse() {
this.addInput("parse", LiteGraph.ACTION);
this.addInput("json", "string");
this.addOutput("done", LiteGraph.EVENT);
this.addOutput("object", "object");
this.widget = this.addWidget("button","parse","",this.parse.bind(this));
this._str = null;
this._obj = null;
}

JSONParse.title = "JSON Parse";
JSONParse.desc = "Parses JSON String into object";

JSONParse.prototype.parse = function()
{
if(!this._str)
return;

try {
this._str = this.getInputData(1);
this._obj = JSON.parse(this._str);
this.boxcolor = "#AEA";
this.triggerSlot(0);
} catch (err) {
this.boxcolor = "red";
}
}

JSONParse.prototype.onExecute = function() {
this._str = this.getInputData(1);
this.setOutputData(1, this._obj);
};

JSONParse.prototype.onAction = function(name) {
if(name == "parse")
this.parse();
}

LiteGraph.registerNodeType("basic/jsonparse", JSONParse);

//to store json objects
function ConstantData() {
this.addOutput("data", "object");
Expand Down

0 comments on commit 015547d

Please sign in to comment.