liveBook · Manning

Invalid json

As explained in Rust Servers, Services, and Apps

Invalid JSON is input text that does not conform to the JSON syntax required for parsing.

Invalid JSON is request input that does not match JSON syntax, such as data missing a double quote or curly brace. In tutor and course create or update APIs, malformed input should become a clear client error rather than silently preventing command execution. section 6.3.5

Malformed API payload

Send a create or update request with malformed JSON—for example, remove a double quote or curly brace. Configure the Actix JSON error handler to produce “Please provide valid Json input” instead of leaving the client without an error message. section 6.3.5

How Rust Servers, Services, and Apps covers it

How deep it goes
Defines an InvalidInput variant, maps it to a message and BAD_REQUEST, and configures Actix JSON error handling.
Examples
Uses malformed tutor or course JSON, such as removing a double quote or curly brace, as the failure case.
What it assumes
Assumes familiarity with JSON API requests, Actix application configuration, and application-level error enums.
What you can do after
Configure Actix JSON handling to diagnose malformed payloads and return a specified message with BAD_REQUEST.
How it connects
Connects JSON parsing with Actix Web, API validation, error handling, and HTTP 400 Bad Request responses.

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.