File: parse.go

package info (click to toggle)
prometheus-nextcloud-exporter 0.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 540 kB
  • sloc: sh: 54; makefile: 54
file content (18 lines) | stat: -rw-r--r-- 344 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package serverinfo

import (
	"encoding/json"
	"io"
)

// ParseJSON reads ServerInfo from a Reader in JSON format.
func ParseJSON(r io.Reader) (*ServerInfo, error) {
	result := struct {
		ServerInfo ServerInfo `json:"ocs"`
	}{}
	if err := json.NewDecoder(r).Decode(&result); err != nil {
		return nil, err
	}

	return &result.ServerInfo, nil
}