when serializing messages, include json objects
This is done always, it's up to the comsumer to decide if it wants to output the json objects or the messages. Messages.JSON.finalize changed to not need a JSONOptions. As far as I can see, this does not change its behavior, since addErrorMessage appends to any list that's already there. This commit was sponsored by Ethan Aubin.
This commit is contained in:
parent
5a41e46bd4
commit
e7f42e2ec7
3 changed files with 28 additions and 18 deletions
|
@ -11,6 +11,7 @@ module Messages.JSON (
|
|||
JSONBuilder,
|
||||
JSONChunk(..),
|
||||
emit,
|
||||
encode,
|
||||
none,
|
||||
start,
|
||||
end,
|
||||
|
@ -38,7 +39,6 @@ import Data.Maybe
|
|||
import Data.Monoid
|
||||
import Prelude
|
||||
|
||||
import Types.Messages
|
||||
import Types.Command (SeekInput(..))
|
||||
import Key
|
||||
import Utility.Metered
|
||||
|
@ -82,12 +82,10 @@ end :: Bool -> JSONBuilder
|
|||
end b (Just (o, _)) = Just (HM.insert "success" (toJSON' b) o, True)
|
||||
end _ Nothing = Nothing
|
||||
|
||||
finalize :: JSONOptions -> Object -> Object
|
||||
finalize jsonoptions o
|
||||
-- Always include error-messages field, even if empty,
|
||||
-- to make the json be self-documenting.
|
||||
| jsonErrorMessages jsonoptions = addErrorMessage [] o
|
||||
| otherwise = o
|
||||
-- Always include error-messages field, even if empty,
|
||||
-- to make the json be self-documenting.
|
||||
finalize :: Object -> Object
|
||||
finalize o = addErrorMessage [] o
|
||||
|
||||
addErrorMessage :: [String] -> Object -> Object
|
||||
addErrorMessage msg o =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue