mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-08-29 07:48:25 +00:00
update aeson to add tag to platform-specific single field JSON encoding (#859)
* update aeson to add tag to platform-specific single field JSON encoding * refactor
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ with-compiler: ghc-9.6.2
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/aeson.git
|
||||
tag: 68330dce8208173c6acf5f62b23acb500ab5d873
|
||||
tag: aab7b5a14d6c5ea64c64dcaee418de1bb00dcc2b
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
|
||||
@@ -107,13 +107,17 @@ enumJSON tagModifier =
|
||||
J.allNullaryToStringTag = True
|
||||
}
|
||||
|
||||
-- used in platform-specific encoding, includes tag for single-field encoding of sum types to allow conversion to tagged objects
|
||||
sumTypeJSON :: (String -> String) -> J.Options
|
||||
#if defined(darwin_HOST_OS) && defined(swiftJSON)
|
||||
sumTypeJSON = singleFieldJSON
|
||||
sumTypeJSON = singleFieldJSON_ $ Just singleFieldJSONTag
|
||||
#else
|
||||
sumTypeJSON = taggedObjectJSON
|
||||
#endif
|
||||
|
||||
singleFieldJSONTag :: String
|
||||
singleFieldJSONTag = "_owsf"
|
||||
|
||||
taggedObjectJSON :: (String -> String) -> J.Options
|
||||
taggedObjectJSON tagModifier =
|
||||
J.defaultOptions
|
||||
@@ -125,10 +129,14 @@ taggedObjectJSON tagModifier =
|
||||
J.omitNothingFields = True
|
||||
}
|
||||
|
||||
-- used in platform independent encoding, doesn't include tag for single-field encoding of sum types
|
||||
singleFieldJSON :: (String -> String) -> J.Options
|
||||
singleFieldJSON tagModifier =
|
||||
singleFieldJSON = singleFieldJSON_ Nothing
|
||||
|
||||
singleFieldJSON_ :: Maybe String -> (String -> String) -> J.Options
|
||||
singleFieldJSON_ objectTag tagModifier =
|
||||
J.defaultOptions
|
||||
{ J.sumEncoding = J.ObjectWithSingleField,
|
||||
{ J.sumEncoding = J.ObjectWithSingleField objectTag,
|
||||
J.tagSingleConstructors = True,
|
||||
J.constructorTagModifier = tagModifier,
|
||||
J.allNullaryToStringTag = False,
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ extra-deps:
|
||||
- text-short-0.1.5@sha256:962c6228555debdc46f758d0317dea16e5240d01419b42966674b08a5c3d8fa6,3498
|
||||
- time-compat-1.9.6.1@sha256:42d8f2e08e965e1718917d54ad69e1d06bd4b87d66c41dc7410f59313dba4ed1,5033
|
||||
- github: simplex-chat/aeson
|
||||
commit: 68330dce8208173c6acf5f62b23acb500ab5d873
|
||||
commit: aab7b5a14d6c5ea64c64dcaee418de1bb00dcc2b
|
||||
- github: kazu-yamamoto/http2
|
||||
commit: b5a1b7200cf5bc7044af34ba325284271f6dff25
|
||||
# - ../direct-sqlcipher
|
||||
|
||||
Reference in New Issue
Block a user