module Text.JSON.JSONPrepend
(
JSONPrepend(..)
) where
import Data.ByteString
import qualified Data.Trie as T
import Text.JSONb
import qualified Text.JSON as J
import qualified Text.HJson as H
import Text.JSON.Types
import qualified Data.Map as M
class JSONPrepend j s | j -> s where
(->:) ::
(s, j)
-> j
-> j
(-->>:) ::
j
-> j
-> j
instance JSONPrepend JSON ByteString where
(k, v) ->: Object x = Object (T.insert k v x)
_ ->: x = x
k -->>: Array x = Array (k : x)
_ -->>: x = x
instance JSONPrepend J.JSValue [Char] where
k ->: (J.JSObject (JSONObject x)) = (J.JSObject (JSONObject (k:x)))
_ ->: x = x
k -->>: J.JSArray x = J.JSArray (k : x)
_ -->>: x = x
instance JSONPrepend H.Json [Char] where
(k, v) ->: H.JObject x = H.JObject (M.insert k v x)
_ ->: x = x
k -->>: H.JArray x = H.JArray (k : x)
_ -->>: x = x