Embedding a Text -> Maybe MyDataType function in a Parser to parse JSON into a custom data type
Modern functional programming and pizza are best friends, so I commend the usage of Haskell here.

As  PizzaType is already its own type, it's probably easiest to implement a FromJSON PizzaType instance. We know Parser is a monad, so we can use &gt;&gt;= to sequence parser computations together.

instance FromJSON PizzaType where
  parseJSON (String s) =
    maybe err pure (convertPizzaType s)
    where
      err = (fail . unpack) ("PizzaType: unknown type " &lt;&gt; s)
  parseJSON invalid =
    typeMismatch "PizzaType" invalid

instance FromJSON PizzaOrder where
  parseJSON (Object v) =
    PizzaOrder &lt;$&gt; (v .: "type" &gt;&gt;= parseJSON) &lt;*&gt; v .: "specialInstructions"
  parseJSON invalid =
    typeMismatch "PizzaOrder" invalid


I also recommend using two helpers:


typeMismatch to make the Aeson errors a little better. It's easy, with large JSON input, to quickly run into error hell where you have no idea where an error is coming from. Best to be specific early on.
maybe to convert values from Maybe a to Parser a.