generated from puria/README
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
If reading slangroom-chain from file we end can end up with a string like:
{
"steps": [
{
"id": "first",
"zencode": "Given nothing\nWhen I write the string 'hello' in 'say hi'\nThen print 'say_hi'",
"onAfter": (result, zencode) => {
const r = JSON.parse(result);
r['say_hi'] = 'hello from onAfter';
result = JSON.stringify(r);
return;
}
},
{
"id": "second",
"dataFromStep": "first",
"zencode": "Given I have a 'string' named 'say_hi'\nThen print the data"
}
]
}
and using JSON.parse() on it, it will obviously brake with error:
SyntaxError: Unexpected token '(', ..."onAfter": (result, z"... is not valid JSON
It could be usefull to have an utility called like chainParse that parse the JSON using an eval on the functions, but checking that the functions take only in input the required input and nothing more. To be thougth carefully since eval can expose to security risks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels