Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
a9c8116f
Verified
Commit
a9c8116f
authored
Jun 19, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[json] bring back previous JSON serialization of Datafield
parent
48057eb5
Pipeline
#4235
failed with stages
in 38 minutes and 52 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
Types.hs
src/Gargantext/API/Node/Corpus/Types.hs
+18
-18
No files found.
src/Gargantext/API/Node/Corpus/Types.hs
View file @
a9c8116f
...
...
@@ -3,7 +3,6 @@
module
Gargantext.API.Node.Corpus.Types
where
import
Control.Lens
hiding
(
elements
,
Empty
)
import
Control.Monad.Fail
(
fail
)
import
Control.Monad.Reader
(
MonadReader
)
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
...
...
@@ -11,7 +10,6 @@ import Data.Monoid (mempty)
import
Data.Swagger
import
GHC.Generics
(
Generic
)
import
Test.QuickCheck
import
qualified
Data.Text
as
T
import
qualified
PUBMED.Types
as
PUBMED
import
Gargantext.Prelude
...
...
@@ -62,23 +60,25 @@ data Datafield = Gargantext
|
Files
deriving
(
Eq
,
Show
,
Generic
)
instance
FromJSON
Datafield
where
parseJSON
=
withText
"Datafield"
$
\
text
->
case
text
of
"Gargantext"
->
pure
Gargantext
"Web"
->
pure
Web
"Files"
->
pure
Files
v
->
case
T
.
breakOnEnd
" "
v
of
(
"External "
,
dbName
)
->
External
<$>
parseJSON
(
String
dbName
)
_
->
fail
$
"Cannot match patterh 'External <db>' for string "
<>
T
.
unpack
v
instance
FromJSON
Datafield
instance
ToJSON
Datafield
-- instance FromJSON Datafield where
-- parseJSON = withText "Datafield" $ \text ->
-- case text of
-- "Gargantext"
-- -> pure Gargantext
-- "Web"
-- -> pure Web
-- "Files"
-- -> pure Files
-- v -> case T.breakOnEnd " " v of
-- ("External ", dbName)
-- -> External <$> parseJSON (String dbName)
-- _ -> fail $ "Cannot match patterh 'External <db>' for string " <> T.unpack v
instance
ToJSON
Datafield
where
toJSON
(
External
db
)
=
toJSON
$
"External "
<>
show
db
toJSON
s
=
toJSON
$
show
s
--
instance ToJSON Datafield where
--
toJSON (External db) = toJSON $ "External " <> show db
--
toJSON s = toJSON $ show s
instance
Arbitrary
Datafield
where
arbitrary
=
oneof
[
pure
Gargantext
,
pure
Web
,
pure
Files
,
External
<$>
arbitrary
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment