Nested Parameters
Parameter values can be any valid JSON value, including nested objects. Let's update our action to use child properties of the event parameters.
Create the
hello-personaction with the following source code.function main(params) { return {payload: 'Hello, ' + params.person.name + ' from ' + params.person.place}; }ic fn action create hello-person hello-person.jsNow the action expects a single
personparameter to have fieldsnameandplace.Invoke the action with a single
personparameter that is valid JSON.ic fn action invoke --result hello-person -p person '{"name": "Elrond", "place": "Rivendell"}'The result is the same because the CLI automatically parses the
personparameter value into the structured object that the action now expects:{ "payload": "Hello, Elrond from Rivendell" }
Last updated
Was this helpful?