mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-28 03:07:07 +02:00
fix: json marshaling
This commit is contained in:
@@ -2,6 +2,7 @@ package proxmox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/luthermonson/go-proxmox"
|
||||
@@ -45,9 +46,8 @@ func (c *Client) Name() string {
|
||||
return c.Cluster.Name
|
||||
}
|
||||
|
||||
// MarshalMap implements pool.Object
|
||||
func (c *Client) MarshalMap() map[string]any {
|
||||
return map[string]any{
|
||||
func (c *Client) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]any{
|
||||
"version": c.Version,
|
||||
"cluster": map[string]any{
|
||||
"name": c.Cluster.Name,
|
||||
@@ -56,7 +56,7 @@ func (c *Client) MarshalMap() map[string]any {
|
||||
"nodes": c.Cluster.Nodes,
|
||||
"quorate": c.Cluster.Quorate,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) NumNodes() int {
|
||||
|
||||
@@ -2,6 +2,7 @@ package proxmox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -38,11 +39,11 @@ func (n *Node) String() string {
|
||||
return fmt.Sprintf("%s (%s)", n.name, n.id)
|
||||
}
|
||||
|
||||
func (n *Node) MarshalMap() map[string]any {
|
||||
return map[string]any{
|
||||
func (n *Node) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]any{
|
||||
"name": n.name,
|
||||
"id": n.id,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (n *Node) Get(ctx context.Context, path string, v any) error {
|
||||
|
||||
Reference in New Issue
Block a user