Documentation
¶
Overview ¶
Package parser provides pluggable parsing of incoming transport payloads (MQTT messages, HTTP webhook bodies) into core.DataPoint values.
Different transport sources speak different wire formats, so different parsers are needed. The "default" parser handles CoreC→CoreC chaining (both sides share the same DataPoint JSON schema); "jsonpath" maps arbitrary JSON fields onto DataPoint via configurable paths; "raw" treats the entire payload as a scalar value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
Parser converts a raw payload (and optional MQTT topic for context) into a DataPoint. Parse is called once per incoming message.
func New ¶
New creates a Parser from a settings map. Recognised keys:
parser.type "default" | "jsonpath" | "raw" (default: "default") parser.driver static string for driver field parser.tag path or static string parser.value path (jsonpath) — for "raw" ignored parser.type-field path or static for DataType parser.group static string parser.device static string parser.timestamp path parser.timestamp-format "rfc3339" | "unix" | "unixmilli" (default: "rfc3339")
When parser.type is absent or "default", the parser is a straight json.Unmarshal into DataPoint — the zero-cost path for CoreC→CoreC.
For "jsonpath", field values use Go template syntax (backward-compatible):
"{{ .payload.dev_id }}" → gjson path "dev_id"
"{{ .topic }}" → the MQTT topic string
"static-string" → literal value