module System.Remote.Json
    (
      encodeAll
    , encodeOne
    ) where

import qualified Data.Aeson as A
import qualified Data.ByteString.Lazy as L

import System.Metrics
import qualified System.Metrics.Json as Json

-- | Encode metrics as nested JSON objects. See 'Json.sampleToJson'
-- for a description of the encoding.
encodeAll :: Sample -> L.ByteString
encodeAll :: Sample -> ByteString
encodeAll = Value -> ByteString
forall a. ToJSON a => a -> ByteString
A.encode (Value -> ByteString) -> (Sample -> Value) -> Sample -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sample -> Value
Json.sampleToJson

-- | Encode metric a JSON object. See 'Json.valueToJson'
-- for a description of the encoding.
encodeOne :: Value -> L.ByteString
encodeOne :: Value -> ByteString
encodeOne = Value -> ByteString
forall a. ToJSON a => a -> ByteString
A.encode (Value -> ByteString) -> (Value -> Value) -> Value -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Value
Json.valueToJson