sec

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonMap

type JsonMap map[string]interface{}

convenience alias for generic json type

type Option

type Option func(*StreamExtractConverter) error

func AttributePrefix

func AttributePrefix(prefix string) Option

Attributes are flattened to become regular members of the converted json object. The supplied prefix will be added to the attribute name for visibility.

func ContentToken

func ContentToken(token string) Option

When attribtues become regular members of the converted json the xml's original value (innertext) needs a key. This token will be used for that - defaults to "value" in accordance with PESC json.

func ObjectsToExtract

func ObjectsToExtract(dataObjects []string) Option

You must specify the objects/xml Types to be extracted and converted from the stream

func ProgressBar

func ProgressBar(streamSize int) Option

Pass the size of the stream to be read in order to display a progress-bar streamSize of 0 will mean no progress-bar displayed

Default is no progress bar

func SampleSize

func SampleSize(size int) Option

Working with big files it can be useful to limit output to a few examples, this sets how many objects will be output from the converter set size to 0 (default) for no restrictions

type Result

type Result struct {
	Name string
	Json []byte
}

Captures output from the converter Name: the class/type/object name of the converted entity Json: the generated json from the converter

type StreamExtractConverter

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

Reads from an xml stream (typically a file), extracts selected object types and converts them to xml. Steam() exposes a channel on which results are published as the stream is parsed

func NewStreamExtractConverter

func NewStreamExtractConverter(r io.Reader, opts ...Option) (*StreamExtractConverter, error)

Initilaises the extractor with the stream to read and the data objects of interest

func (*StreamExtractConverter) Stream

func (sec *StreamExtractConverter) Stream() chan Result

Invokes the parsing and converting of the input stream, and channel can be ranged over to collect json blob results

Jump to

Keyboard shortcuts

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