{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}

-- | Pretty-printing JSON values.
module Text.JSON.JSONPrint
(
  JSONPrint(..)
) where

import Data.ByteString
import Text.JSONb
import qualified Text.JSON as J
import Text.JSON.Pretty

-- | Pretty-printing JSON values.
class JSONPrint j s | j -> s where
  -- | Print the given JSON value to a pretty-printed value.
  printJSON ::
    j -- ^ The JSON value.
    -> s -- ^ The pretty-printed result.

instance JSONPrint JSON ByteString where
  printJSON =
    encode Compact

instance JSONPrint J.JSValue [Char] where
  printJSON =
    render . pp_value