json

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package json contains the json node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONConfig

type JSONConfig struct {
	// Action selects the conversion: "" (auto: stringify objects, parse
	// strings) | "str" (always stringify) | "obj" (always parse)
	Action string `json:"action"`
	// Property is the message field to convert; "payload" (default)
	// targets msg.Payload, otherwise a dotted path inside the data map
	Property string `json:"property"`
	// Pretty indents stringified output with two spaces
	Pretty bool `json:"pretty"`
	// Outputs is the node port count; 2 adds a second port that receives
	// messages whose JSON failed to parse (error info in Metadata.error)
	Outputs int `json:"outputs"`
}

JSONConfig 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.

type JSONNode

type JSONNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

JSONNode converts payload data between string and object form.

func NewJSONNode

func NewJSONNode(node nodestore.NodeInterface, config *JSONConfig) *JSONNode

NewJSONNode creates a new json node

func (*JSONNode) Execute

Execute 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.

func (*JSONNode) SelectPorts

func (n *JSONNode) SelectPorts(input, output nodestore.MessageInterface) []string

SelectPorts routes the message to output_2 when the last Execute hit a parse error, otherwise to output_1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL