Changed error return to send object too (if server returns valid json)