Better types, JSON support and threshold checking

This brings in the following changes:

- Thresholds now have a min and max property
- JSON parsing is now done through aeson decode
- This breaks compatibility with the previous JSON structure