Help us shape the future of Go! Take the 2026 Go Developer Survey

xmlconv

package
v1.16.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountListItems

func CountListItems(xmlData []byte) (int, error)

CountListItems counts the direct child elements of the XML root, excluding any <size> element. This is purpose-built for Jamf Classic API list endpoints like /JSSResource/policies which return:

<policies><size>2</size><policy>...</policy><policy>...</policy></policies>

func ExtractListItems

func ExtractListItems(xmlData []byte) ([]map[string]any, error)

ExtractListItems extracts the repeated child elements from a Classic API list XML response as a slice of maps, skipping <size>. Each child element is recursively converted to a map.

func IsXML

func IsXML(data []byte) bool

IsXML returns true if data appears to be XML (starts with '<' after whitespace).

func ToJSON

func ToJSON(xmlData []byte) ([]byte, error)

ToJSON converts XML bytes to JSON bytes. The root XML element becomes the top-level JSON key: <policy>...</policy> → {"policy": {...}}.

Collection elements that contain a <size> child are treated as arrays: their non-<size> children are collected into a JSON array. This matches the Jamf Classic API convention where list containers always include <size>.

func ToMap

func ToMap(xmlData []byte) (map[string]any, error)

ToMap converts XML bytes to a map. The root element name is the top-level key. See ToJSON for array-detection heuristics.

Types

This section is empty.

Jump to

Keyboard shortcuts

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