proto-lens-jsonpb 0.2.0.2 → 0.2.1
raw patch · 2 files changed
+20/−26 lines, 2 filesdep ~aesondep ~bytestringnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, bytestring
API changes (from Hackage documentation)
Files
proto-lens-jsonpb.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: proto-lens-jsonpb-version: 0.2.0.2+version: 0.2.1 synopsis: JSON protobuf encoding for proto-lens description: Please see the README on GitHub at <https://github.com/tclem/proto-lens-jsonpb#readme> homepage: https://github.com/tclem/proto-lens-jsonpb#readme@@ -15,9 +15,9 @@ build-type: Simple extra-source-files: README.md -tested-with: GHC == 8.6.5- , GHC == 8.8.1- , GHC == 8.10.1+tested-with: GHC == 8.10.1+ , GHC == 9.0.1+ , GHC == 9.2.1 -- GHC extensions shared between targets common haskell@@ -40,8 +40,8 @@ common dependencies build-depends: base >=4.7 && <5- , aeson >=1.4 && <1.6- , bytestring >= 0.10.8+ , aeson >= 1.4.2.0 && < 3+ , bytestring >= 0.10.8.2 && < 0.13 , proto-lens-runtime >= 0.5 && <0.8 , text ^>= 1.2.3.2 , vector >= 0.12.0.3
src/Data/ProtoLens/JSONPB/Class.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE FlexibleInstances, OverloadedLists, RecordWildCards, ScopedTypeVariables, ViewPatterns #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wno-orphans #-} -- Ported from https://github.com/awakesecurity/proto3-suite (Apache v2 License)@@ -54,30 +58,20 @@ -- @ module Data.ProtoLens.JSONPB.Class where -import qualified Data.Aeson as A- ( Encoding- , FromJSON (..)- , FromJSONKey (..)- , FromJSONKeyFunction (..)- , ToJSON (..)- , Value (..)- , eitherDecode- , json- , (.!=)- )+import qualified Data.Aeson as A (Encoding, FromJSON(..), FromJSONKey(..), FromJSONKeyFunction(..), ToJSON(..), Value(..), eitherDecode, json, (.!=)) import qualified Data.Aeson.Encoding as E import qualified Data.Aeson.Internal as A (formatError, iparse) import qualified Data.Aeson.Parser as A (eitherDecodeWith)-import qualified Data.Aeson.Types as A- (Object, Pair, Parser, Series, explicitParseField, explicitParseFieldMaybe, object, typeMismatch)+import qualified Data.Aeson.Types as A (Object, Pair, Parser, Series, explicitParseField, explicitParseFieldMaybe, object, typeMismatch) import qualified Data.Attoparsec.ByteString as Atto (skipWhile) import qualified Data.Attoparsec.ByteString.Char8 as Atto (Parser, endOfInput) import qualified Data.ByteString as BS import qualified Data.ByteString.Base64 as B64 import qualified Data.ByteString.Lazy as LBS-import Data.ProtoLens.Runtime.Data.ProtoLens (FieldDefault (..))-import Data.Text (Text)+import Data.ProtoLens.Runtime.Data.ProtoLens (FieldDefault(..))+import Data.String (fromString)+import Data.Text (Text, unpack) import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as TL@@ -141,10 +135,10 @@ pair :: ToJSONPB v => Text -> v -> Options -> m instance KeyValuePB A.Series where- pair k v opts = E.pair k (toEncodingPB v opts)+ pair k v opts = E.pair (fromString (unpack k)) (toEncodingPB v opts) instance KeyValuePB [A.Pair] where- pair k v opts = pure (k, toJSONPB v opts)+ pair k v opts = pure (fromString (unpack k), toJSONPB v opts) -- | Construct a monoidal key-value pair, using 'mempty' to represent omission -- of default values (unless the given 'Options' force their emission).@@ -160,12 +154,12 @@ -- object, or if it is present but its value is null, we produce the default -- protobuf value for the field type (.:) :: (FromJSONPB a, FieldDefault a) => A.Object -> Text -> A.Parser a-obj .: key = obj .:? key A..!= fieldDefault+obj .: key = obj .:? fromString (unpack key) A..!= fieldDefault where (.:?) = A.explicitParseFieldMaybe parseJSONPB parseField :: FromJSONPB a => A.Object -> Text -> A.Parser a-parseField = A.explicitParseField parseJSONPB+parseField o = A.explicitParseField parseJSONPB o . fromString . unpack -- * JSONPB rendering and parsing options data Options =