Bug fix for processing JSON in unexpected formats