JSON Patch
JSON Patch (RFC 6902)
A format for describing a sequence of operations to modify a JSON document (add, remove, replace, move).
Détail technique
JSON Patch is defined by RFC 8259 and ECMA-404. It supports six data types: string, number, object, array, boolean, and null. JSON numbers have no distinction between integer and float — implementations must handle precision carefully (JavaScript's Number.MAX_SAFE_INTEGER is 2^53 - 1). JSON does not support comments, trailing commas, or single quotes, which are common sources of parse errors. JSON5 and JSONC extend the format with these developer-friendly features.
Exemple
```javascript
// Parse JSON with error handling
try {
const data = JSON.parse(rawString);
console.log(data.name); // access properties
} catch (e) {
console.error('Invalid JSON:', e.message);
}
// Serialize with formatting
const pretty = JSON.stringify(obj, null, 2);
```