lsp-types-2.2.0.0: Haskell library for the Microsoft Language Server Protocol, data types
Safe HaskellNone
LanguageGHC2021

Data.Row.Aeson

Description

This module defines orphan aeson instances for Row. They differ from the instances in `row-types-aeson` in one crucial respect: they serialise Nothing fields by *omitting* them in the resulting object, and parse absent fields as Nothing. aeson can be configured to have this behviour for instances for datatypes, but we want to do this for record types generically.

This is crucial to match what LSP clients expect.

Synopsis

Documentation

class ToJSONEntry a where #

Serialise a value as an entry in a JSON object. This allows customizing the behaviour in the object context, in order to e.g. omit the field.

Methods

toJSONEntry :: String -> a -> Object #

Instances

Instances details
ToJSON a => ToJSONEntry a # 
Instance details

Defined in Data.Row.Aeson

Methods

toJSONEntry :: String -> a -> Object #

ToJSON a => ToJSONEntry (Maybe a) # 
Instance details

Defined in Data.Row.Aeson

Methods

toJSONEntry :: String -> Maybe a -> Object #

class FromJSONEntry a where #

Methods

parseJSONEntry :: Object -> String -> Parser a #

Instances

Instances details
FromJSON a => FromJSONEntry a # 
Instance details

Defined in Data.Row.Aeson

Methods

parseJSONEntry :: Object -> String -> Parser a #

FromJSON a => FromJSONEntry (Maybe a) # 
Instance details

Defined in Data.Row.Aeson

lazyUncons :: forall (l :: Symbol) (r :: Row Type). KnownSymbol l => Label l -> Rec r -> (Rec (r .- l), r .! l) #

Orphan instances

(AllUniqueLabels r, Forall r FromJSONEntry) => FromJSON (Rec r) # 
Instance details

Forall r ToJSONEntry => ToJSON (Rec r) # 
Instance details

Methods

toJSON :: Rec r -> Value #

toEncoding :: Rec r -> Encoding #

toJSONList :: [Rec r] -> Value #

toEncodingList :: [Rec r] -> Encoding #

omitField :: Rec r -> Bool #