Documentation ¶
Overview ¶
Package xml2json is an XML to JSON converter
Index ¶
- func TrimNonGraphic(s string) string
- type Converter
- type Decoder
- func (dec *Decoder) Decode(root *Node) error
- func (dec *Decoder) DecodeWithCustomPrefixes(root *Node, contentPrefix string, attributePrefix string) error
- func (dec *Decoder) ExcludeAttributes(attrs []string)
- func (dec *Decoder) SetAttributePrefix(prefix string)
- func (dec *Decoder) SetContentPrefix(prefix string)
- type Encoder
- type JSType
- type Node
- type Nodes
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TrimNonGraphic ¶
TrimNonGraphic returns a slice of the string s, with all leading and trailing non graphic characters and spaces removed.
Graphic characters include letters, marks, numbers, punctuation, symbols, and spaces, from categories L, M, N, P, S, Zs. Spacing characters are set by category Z and property Pattern_White_Space.
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
func NewConverter ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes XML objects from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from reader.
func (*Decoder) Decode ¶
Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v.
func (*Decoder) DecodeWithCustomPrefixes ¶
func (*Decoder) ExcludeAttributes ¶
func (*Decoder) SetAttributePrefix ¶
func (*Decoder) SetContentPrefix ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes JSON objects to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to writer.
type JSType ¶
type JSType int
https://cswr.github.io/JsonSchema/spec/basic_types/ JSType is a JavaScript extracted from a string
func Str2JSType ¶
Str2JSType extract a JavaScript type from a string
type Node ¶
Node is a data element on a tree
type Plugin ¶
Plugin is added to an encoder or/and to an decoder to allow custom functionality at runtime
func AllAttrToArray ¶
func AllAttrToArray() Plugin
func AttrToArray ¶
func ExcludeAttributes ¶
ExcludeAttributes excludes some xml attributes, for example, xmlns:xsi, xsi:noNamespaceSchemaLocation
func WithAttrPrefix ¶
WithAttrPrefix appends the given prefix to the json output of xml attribute fields to preserve namespaces
func WithContentPrefix ¶
WithContentPrefix appends the given prefix to the json output of xml content fields to preserve namespaces
func WithTypeConverter ¶
WithTypeConverter allows customized js type conversion behavior by passing in the desired JSTypes