mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
Update json.go
This commit is contained in:
parent
0a8b820725
commit
d0ff7b58c5
1 changed files with 7 additions and 2 deletions
|
|
@ -6,10 +6,15 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Shared JSON serialization for registry types to avoid duplication.
|
||||||
|
func marshalRegistryJSON(r Registry) ([]byte, error) {
|
||||||
|
return json.Marshal(r.GetAll())
|
||||||
|
}
|
||||||
|
|
||||||
// MarshalJSON returns a byte slice containing a JSON representation of all
|
// MarshalJSON returns a byte slice containing a JSON representation of all
|
||||||
// the metrics in the Registry.
|
// the metrics in the Registry.
|
||||||
func (r *StandardRegistry) MarshalJSON() ([]byte, error) {
|
func (r *StandardRegistry) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(r.GetAll())
|
return marshalRegistryJSON(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteJSON writes metrics from the given registry periodically to the
|
// WriteJSON writes metrics from the given registry periodically to the
|
||||||
|
|
@ -27,5 +32,5 @@ func WriteJSONOnce(r Registry, w io.Writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PrefixedRegistry) MarshalJSON() ([]byte, error) {
|
func (r *PrefixedRegistry) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(r.GetAll())
|
return marshalRegistryJSON(r)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue