parser

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJsonMessage

func ParseJsonMessage(dataJson string) ([]interface{}, error)

ParseJsonMessage Unmarshals an OCPP-J json object from a JSON string. Returns the array of elements contained in the message.

func ParseRawJsonMessage

func ParseRawJsonMessage(dataJson []byte) ([]interface{}, error)

ParseRawJsonMessage Unmarshals an OCPP-J json object from a byte array. Returns the array of elements contained in the message.

Types

type ParserV2 added in v0.3.0

type ParserV2 struct {
	// contains filtered or unexported fields
}

ParserV2 is used for parsing multiple OCPP-J messages. It is stateful, as it will all results of the parsing process. Particularly needed for parsing files that contain request-response pairs, where the response is dependent on the request. It will return a map of unique IDs to RequestResponseResult, where RequestResponseResult is a struct that contains the parsed message and any errors that occurred during parsing.

func NewParserV2 added in v0.3.0

func NewParserV2(logger *zap.Logger) *ParserV2

func (*ParserV2) Parse added in v0.3.0

func (fp *ParserV2) Parse(data []string) (map[string]RequestResponseResult, map[string]Result, error)

Parse takes an array of OCPP-J messages and parses them. It returns a map of unique IDs to RequestResponseResult.

type RequestResponseResult added in v0.3.0

type RequestResponseResult struct {
	// Request is the parsed OCPP request message.
	Request Result

	// Response can be either ocpp.CallResult or ocpp.CallError (or nil if no request was provided).
	Response Result

	// ResponseError
	ResponseError Result
}

func NewRequestResponseResult added in v0.3.0

func NewRequestResponseResult() *RequestResponseResult

func (*RequestResponseResult) AddRequest added in v0.3.0

func (r *RequestResponseResult) AddRequest(request ocpp.Message)

func (*RequestResponseResult) AddRequestError added in v0.3.0

func (r *RequestResponseResult) AddRequestError(err string)

func (*RequestResponseResult) AddResponse added in v0.3.0

func (r *RequestResponseResult) AddResponse(response ocpp.Message)

func (*RequestResponseResult) AddResponseError added in v0.3.0

func (r *RequestResponseResult) AddResponseError(err string)

func (*RequestResponseResult) AddResponseErrorError added in v0.4.0

func (r *RequestResponseResult) AddResponseErrorError(err string)

func (*RequestResponseResult) AddResponseErrorResult added in v0.4.0

func (r *RequestResponseResult) AddResponseErrorResult(response ocpp.Message)

func (*RequestResponseResult) GetRequest added in v0.3.0

func (r *RequestResponseResult) GetRequest() (ocpp.Message, bool)

func (*RequestResponseResult) GetResponse added in v0.3.0

func (r *RequestResponseResult) GetResponse() (ocpp.Message, bool)

func (*RequestResponseResult) GetResponseError added in v0.4.0

func (r *RequestResponseResult) GetResponseError() (ocpp.Message, bool)

func (*RequestResponseResult) IsValid added in v0.3.0

func (r *RequestResponseResult) IsValid() bool

type Result

type Result struct {
	// contains filtered or unexported fields
}

func NewResult

func NewResult() *Result

NewResult creates a new Result with the given validity and errors.

func (*Result) AddError

func (v *Result) AddError(err string)

func (*Result) Errors

func (v *Result) Errors() []string

func (*Result) IsValid

func (v *Result) IsValid() bool

func (*Result) Message added in v0.3.0

func (v *Result) Message() ocpp.Message

func (*Result) SetMessage added in v0.3.0

func (v *Result) SetMessage(message ocpp.Message)

Jump to

Keyboard shortcuts

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