pa-json 0.1.1.1 → 0.2.0.0
raw patch · 3 files changed
+15/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +8/−0
- pa-json.cabal +1/−1
- src/Json/Enc.hs +6/−4
CHANGELOG.md view
@@ -1,5 +1,13 @@ # Revision history for pa-json +## 0.2.0.0 -- 2023-06-15++* `Json.Enc`: Add `Show` instance which pretty-prints to a json string+* `Json.Enc`: Add encoding functions+* `Json.Enc.object`: Keep first element on duplicate keys instead of second+* `Json.Enc.object`: Keep order of elements (go through list instead of map)++ ## 0.1.0.0 -- 2023-05-24 - First version
pa-json.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 -- !!! ATTN: file autogenerated from pa-template.cabal.mustache on toplevel !!! name: pa-json-version: 0.1.1.1+version: 0.2.0.0 synopsis: Our JSON parsers/encoders description: The interface of `aeson` is unfortunately extremely … suboptimal. Here’s some wrappers trying to improve the situation, which we use internally. license: BSD-3-Clause
src/Json/Enc.hs view
@@ -13,7 +13,9 @@ import Data.Aeson.KeyMap (KeyMap) import Data.Aeson.KeyMap qualified as KeyMap import Data.ByteString.Lazy qualified as LazyBytes+import Data.Containers.ListUtils (nubOrdOn) import Data.Int (Int64)+import Data.List qualified as List import Data.Map.Strict qualified as Map import Data.Scientific import Data.String (IsString (fromString))@@ -122,11 +124,11 @@ -- | Encode the given list of keys and their encoders as 'Object'. ----- Like with 'Map.fromList', if the list contains the same key multiple times, the last value in the list is retained:+-- If the list contains the same key multiple times, the first value in the list is retained: -- -- @ -- (object [ ("foo", 42), ("foo", 23) ])--- ~= "{\"foo\":23}"+-- ~= "{\"foo\":42}" -- @ object :: Foldable t => t (Text, Enc) -> Enc object m =@@ -134,8 +136,8 @@ AesonEnc.dict AesonEnc.text (\recEnc -> recEnc.unEnc)- Map.foldrWithKey- (Map.fromList $ toList m)+ (\f -> List.foldr (\(k, v) -> f k v))+ (nubOrdOn fst $ toList m) -- | A tag/value encoder; See 'choice' data Choice = Choice Text Enc