+ // Ensure subsequent calls receive error instance.
+ $this->parsed_json = false;
+
+ $error_data = array(
+ 'status' => WP_Http::BAD_REQUEST,
+ );
+ if ( function_exists( 'json_last_error' ) ) {
+ $error_data['json_error_code'] = json_last_error();
+ $error_data['json_error_message'] = json_last_error_msg();
+ }
+
+ return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data );