cleaner implementation of JSON parser working