xml2json-0.2.0.0: translate xml to json

Safe HaskellNone

Text.XML.ToJSON

Contents

Synopsis

Documentation

This library provide a way to convert xml to json.

Further more, by combining with aeson's parsing facility, it provide a way to parse xml to haskell data type.

parseXML :: (MonadThrow m, FromJSON a) => ByteString -> m aSource

parse xml to haskell data type by using aeson's FromJSON.

xmlToJSON :: MonadThrow m => ByteString -> m ValueSource

convert lazy xml ByteString to aeson Value.

streamlined api

bsSourceToJSON :: MonadThrow m => Source m ByteString -> m ValueSource

Consume a source and convert the content to aeson Value, it try to inspect xml encoding from first tag.

e.g. bsSourceToJSON (C.sourceFile path_to_xml_file)

bsRSourceToJSON :: MonadThrow m => ResumableSource m ByteString -> m ValueSource

Consume a source and convert the content to aeson Value, it try to inspect xml encoding from first tag.

e.g. xmlStreamToJSONResumable (requestBody req)

utils

tokenToBuilder :: Token -> BuilderSource

Convert tagstream-conduit Token to xml element Builder

elementToJSON :: Element -> ValueSource

Convert xml Element to aeson Value .

xml attributes and text values are converted to special object attribute __attributes and __values.

tokensToJSON :: [Token] -> ValueSource

Convert list of tagstream-conduit Token to aeson Value