packages feed

sarif-0.2: src/Data/SARIF/SpecialLocations.hs

--------------------------------------------------------------------------------
-- SARIF implementation for Haskell
--------------------------------------------------------------------------------
-- This source code is licensed under the MIT license found in the LICENSE    --
-- file in the root directory of this source tree.                            --
--------------------------------------------------------------------------------

-- | Provides the `SpecialLocations` type to represent SARIF artifacts.
module Data.SARIF.SpecialLocations (SpecialLocations (..)) where

import Data.Aeson.Optional
import Data.Map.Strict
import Data.SARIF.ArtifactLocation
import Data.Text

data SpecialLocations
  = MkSpecialLocations
      { -- | The displayBase property of the special locations
        specialLocationsDisplayBase :: Maybe ArtifactLocation
        -- | The properties property of the SpecialLocations object
      , specialLocationsProperties :: Maybe (Map Text Value)
      }
  deriving (Eq, Ord, Show)

instance ToJSON SpecialLocations where
  toJSON MkSpecialLocations {..} =
    object
      [ "displayBase" .=? specialLocationsDisplayBase,
        "properties" .=? specialLocationsProperties
      ]

instance FromJSON SpecialLocations where
  parseJSON = withObject "SpecialLocations" $ \obj ->
    MkSpecialLocations
      <$> obj .:? "displayBase"
      <*> obj .:? "properties"