fixed JSON parsing, and add field checking to avoid exception