Refactored coerceToType

By primarily switching on the target type than the input type, the
resulting code becomes easier to understand. Particularly the handling
when the client desires a JsonValue no longer requires an if-statement,
but becomes part of the root pattern matching

Also it makes it easier to implement a 'JsonValue option' target type.