{"modulePath":"github.com/dracory/nodebase","version":"v0.15.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package json\n\nPackage json contains the json node implementation.\n\n## Types\n\n```go\ntype JSONConfig struct {\n\t// Action selects the conversion: \"\" (auto: stringify objects, parse\n\t// strings) | \"str\" (always stringify) | \"obj\" (always parse)\n\tAction string `json:\"action\"`\n\t// Property is the message field to convert; \"payload\" (default)\n\t// targets msg.Payload, otherwise a dotted path inside the data map\n\tProperty string `json:\"property\"`\n\t// Pretty indents stringified output with two spaces\n\tPretty bool `json:\"pretty\"`\n\t// Outputs is the node port count; 2 adds a second port that receives\n\t// messages whose JSON failed to parse (error info in Metadata.error)\n\tOutputs int `json:\"outputs\"`\n}\n```\nJSONConfig holds configuration for the json node — the Node-RED JSON parser equivalent. Converts the configured property between a JSON string and its decoded object representation.\n\n```go\ntype JSONNode struct {\n\t*nodebase.BaseNode\n\t// contains filtered or unexported fields\n}\n```\nJSONNode converts payload data between string and object form.\n\n```go\nfunc NewJSONNode(node nodestore.NodeInterface, config *JSONConfig) *JSONNode\n```\nNewJSONNode creates a new json node\n\n```go\nfunc (n *JSONNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)\n```\nExecute reads the configured property, converts it and writes the result back. A parse failure either routes to output\\_2 (when the node has two outputs) or aborts the branch with an error status.\n\n```go\nfunc (n *JSONNode) SelectPorts(input, output nodestore.MessageInterface) []string\n```\nSelectPorts routes the message to output\\_2 when the last Execute hit a parse error, otherwise to output\\_1.\n\n","path":"github.com/dracory/nodebase/json","name":"json","synopsis":"Package json contains the json node implementation.","isRedistributable":true}
