THRIFT-3145 JSON protocol does not handle bool and empty containers correctly
Client: Haskell
Patch: Rhys Adams
Fix deserialization of empty list and set.
diff --git a/lib/hs/src/Thrift/Protocol/JSON.hs b/lib/hs/src/Thrift/Protocol/JSON.hs
index f378ea2..ba19ad7 100644
--- a/lib/hs/src/Thrift/Protocol/JSON.hs
+++ b/lib/hs/src/Thrift/Protocol/JSON.hs
@@ -149,14 +149,16 @@
between '{' '}' (parseJSONMap kt vt)
parseJSONValue (T_LIST ty) = fmap (TList ty) $
between '[' ']' $ do
- len <- lexeme escapedString *> lexeme (PC.char8 ',') *>
- lexeme decimal <* lexeme (PC.char8 ',')
- if len > 0 then parseJSONList ty else return []
+ len <- lexeme escapedString *> lexeme (PC.char8 ',') *> lexeme decimal
+ if len > 0
+ then lexeme (PC.char8 ',') *> parseJSONList ty
+ else return []
parseJSONValue (T_SET ty) = fmap (TSet ty) $
between '[' ']' $ do
- len <- lexeme escapedString *> lexeme (PC.char8 ',') *>
- lexeme decimal <* lexeme (PC.char8 ',')
- if len > 0 then parseJSONList ty else return []
+ len <- lexeme escapedString *> lexeme (PC.char8 ',') *> lexeme decimal
+ if len > 0
+ then lexeme (PC.char8 ',') *> parseJSONList ty
+ else return []
parseJSONValue T_BOOL =
(TBool True <$ string "true") <|> (TBool False <$ string "false")
parseJSONValue T_BYTE = TByte <$> signed decimal