Add flag support for JSON deserializer

This PR adds the flag support for the JSON deserializer and targets #361.
Please review carefully and ask me to add more tests if you like!
Add a blank line below this one.