more OsPath conversion (602/749)
Sponsored-by: Brock Spratlen
This commit is contained in:
parent
2d1db7986c
commit
a5d48edd94
25 changed files with 227 additions and 187 deletions
|
@ -34,6 +34,7 @@ module Messages.JSON (
|
|||
import Control.Applicative
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Vector as V
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Aeson.KeyMap as HM
|
||||
import System.IO
|
||||
|
@ -84,7 +85,7 @@ start command file key si _ = case j of
|
|||
j = toJSON' $ JSONActionItem
|
||||
{ itemCommand = Just command
|
||||
, itemKey = key
|
||||
, itemFile = fromOsPath <$> file
|
||||
, itemFile = file
|
||||
, itemUUID = Nothing
|
||||
, itemFields = Nothing :: Maybe Bool
|
||||
, itemSeekInput = si
|
||||
|
@ -98,7 +99,7 @@ startActionItem command ai si _ = case j of
|
|||
j = toJSON' $ JSONActionItem
|
||||
{ itemCommand = Just command
|
||||
, itemKey = actionItemKey ai
|
||||
, itemFile = fromOsPath <$> actionItemFile ai
|
||||
, itemFile = actionItemFile ai
|
||||
, itemUUID = actionItemUUID ai
|
||||
, itemFields = Nothing :: Maybe Bool
|
||||
, itemSeekInput = si
|
||||
|
@ -206,7 +207,7 @@ instance ToJSON' a => ToJSON' (ObjectMap a) where
|
|||
data JSONActionItem a = JSONActionItem
|
||||
{ itemCommand :: Maybe String
|
||||
, itemKey :: Maybe Key
|
||||
, itemFile :: Maybe FilePath
|
||||
, itemFile :: Maybe OsPath
|
||||
, itemUUID :: Maybe UUID
|
||||
, itemFields :: Maybe a
|
||||
, itemSeekInput :: SeekInput
|
||||
|
@ -220,7 +221,9 @@ instance ToJSON' a => ToJSON' (JSONActionItem a) where
|
|||
Just k -> Just $ "key" .= toJSON' k
|
||||
Nothing -> Nothing
|
||||
, case itemFile i of
|
||||
Just f -> Just $ "file" .= toJSON' f
|
||||
Just f ->
|
||||
let f' = (fromOsPath f) :: S.ByteString
|
||||
in Just $ "file" .= toJSON' f'
|
||||
Nothing -> Nothing
|
||||
, case itemFields i of
|
||||
Just f -> Just $ "fields" .= toJSON' f
|
||||
|
@ -235,7 +238,7 @@ instance FromJSON a => FromJSON (JSONActionItem a) where
|
|||
parseJSON (Object v) = JSONActionItem
|
||||
<$> (v .:? "command")
|
||||
<*> (maybe (return Nothing) parseJSON =<< (v .:? "key"))
|
||||
<*> (v .:? "file")
|
||||
<*> (fmap stringToOsPath <$> (v .:? "file"))
|
||||
<*> (v .:? "uuid")
|
||||
<*> (v .:? "fields")
|
||||
-- ^ fields is used for metadata, which is currently the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue