parser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 8 Imported by: ? modules, 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 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

type Parser interface {
	Parse(payload []byte, topic string) (core.DataPoint, error)
}

Parser converts a raw payload (and optional MQTT topic for context) into a DataPoint. Parse is called once per incoming message.

func New

func New(settings map[string]any) (Parser, error)

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

Jump to

Keyboard shortcuts

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