Skip to content

Commit

Permalink
Bump resolver to lts-20.26
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidEichmann committed Aug 7, 2023
1 parent acad32c commit 1958b57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/Text/XML/JSON/XmlToJson.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module Text.XML.JSON.XmlToJson(xmlToJson, Flag(..)) where

import Control.Applicative ((*>), (<*))
import Control.Arrow (first, (&&&), (***), (>>>))
import Control.Arrow ((&&&), (***), (>>>))
import Control.Arrow.ArrowTree (ArrowTree)
import Control.Category (id)
import Control.Monad (forM_)
import Data.Maybe (catMaybes)
import Data.Tree.NTree.TypeDefs
import Data.Tree.Class (Tree)
import Data.Tree.Class (Tree)
import Prelude hiding (id)
import Text.Regex.Posix ((=~))
import Text.XML.HXT.Core (ArrowXml, XNode (..), XmlTree,
Expand All @@ -21,14 +20,13 @@ import Text.XML.HXT.Curl -- use libcurl for HTTP access, only necessary when rea
#endif

import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Key as AesonKey
import qualified Data.ByteString.Lazy.Char8 as BS
import qualified Data.HashMap.Strict as HashMap
import qualified Data.Map as M
import qualified Data.Text as T
import qualified Data.Vector as Vector
import Text.XML.HXT.Expat (withExpat)


data Flag = Input String | StartFrom String | Multiline | SkipRoots | NoIgnoreNulls | WrapArray | NoCollapseText String | ShowHelp
deriving (Show, Eq)

Expand Down Expand Up @@ -104,10 +102,11 @@ arrayValuesToJSONArrays = M.mapMaybe f
f [x] = Just x -- don't store as array, just a single value
f xss = Just $ Aeson.Array . Vector.fromList $ xss -- arrays with more than one element are kept

packJSValueName :: JSValueName -> T.Text
packJSValueName Text = T.pack "value"
packJSValueName (Attr x) = T.pack x
packJSValueName (Tag x) = T.pack x
packJSValueName :: JSValueName -> Aeson.Key
packJSValueName jsValueName = AesonKey.fromString $ case jsValueName of
Text -> "value"
Attr x -> x
Tag x -> x

wrapRoot :: Maybe (JSValueName, Aeson.Value) -> Aeson.Value
wrapRoot Nothing = Aeson.Null
Expand All @@ -119,7 +118,7 @@ tagMapToJSValue :: Bool -> M.Map JSValueName Aeson.Value -> Aeson.Value
tagMapToJSValue collapseTextRegex m = case (collapseTextRegex, M.toList m) of
(True, [(Text, val)]) -> val
_ ->
Aeson.Object . HashMap.fromList . (map . first) packJSValueName $ M.toList m
Aeson.object [(packJSValueName k, v) | (k, v) <- M.toList m]

xmlTreeToJSON :: Maybe String -> XmlTree -> Maybe (JSValueName, Aeson.Value)
xmlTreeToJSON collapseTextRegex node@(NTree (XTag qName _) children)
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# resolver:
# name: custom-snapshot
# location: "./custom-snapshot.yaml"
resolver: lts-6.7
resolver: lts-20.26

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down

0 comments on commit 1958b57

Please sign in to comment.