FYI you don't have to test both of these things, its good enough test:

    isset( $error_json['error']['code'] )

and PHP will do the right thing even if 'error' is not set.