Aller au contenu
uencoder

Appliquer JSON Patch (RFC 6902) operations

JSON Patch defines un sequence de operations (ajouter, supprimer, remplacer, move, copy, tester) en modify un JSON document atomically.

  1. 1

    JSON Patch (RFC 6902) applies an array of operations to a JSON document. Operations: add (insert or replace), remove (delete), replace (overwrite), move (relocate), copy (duplicate), test (assert value before proceeding). Each operation uses a JSON Pointer path.

  2. 2
    Formateur JSON →

    Formater both the original document and the patch array to verify they are valid JSON. The patch is an array of {op, path, value?} objects. Format them to catch syntax errors before applying.

  3. 3
    Validateur JSON →

    Valider the patch structure: each operation must have "op" (one of add/remove/replace/move/copy/test) and "path" (a JSON Pointer). Add and replace require "value"; move and copy require "from"; test requires "value" for comparison.

  4. 4

    The "test" operation is powerful for conditional patches: it verifies a value before applying subsequent operations. If any test fails, the entire patch is rejected (atomicity). Use test to implement optimistic concurrency: test the version field, then apply changes.

Questions fréquentes

Is JSON Patch atomic?
Yes. If any operation fails (e.g., test assertion fails, path does not exist for remove), the entire patch is rejected and the document is unchanged. This makes it safe for concurrent modifications with proper version testing.
JSON Patch vs JSON Merge Patch?
JSON Patch (RFC 6902) uses explicit operations (add/remove/replace) — more expressive. JSON Merge Patch (RFC 7396) is simpler: a single JSON object where null means delete and other values mean replace. Use Merge Patch for simple updates, JSON Patch for complex operations.

Workflows résolvant cette tâche

Convertir la casse de nommage et valider en JSON
Convertir les identifiants en convention de nommage cible, puis valider le résultat en JSON pour confirmer la structure.
PIPELINE
Comparer deux configs YAML via JSON
Convertir les configs YAML en JSON pour une comparaison diff-friendly des valeurs structurées.
PIPELINE
Coder une charge utile JSON pour transport URL
Préparer un Document JSON pour un Paramètre URL: embellir, Coder en Base64, puis encodage pourcent — le inverse exacte de le chaîne de décodage de paramètres imbriqués.
PIPELINE
HJSON en format JSON
Formater HJSON et convertir en JSON standard.
PIPELINE
Formater JS et valider JSON
Formater le code JS puis valider en JSON.
PIPELINE
Formater JSON et calculer une somme de contrôle d'intégrité
Pretty-printer un document JSON et calculer une somme CRC32 pour détecter toute modification ultérieure.
PIPELINE
Minifier et valider JSON
Formater JSON pour inspection et valider sa correction syntaxique en une passe.
PIPELINE
Générer JSON Schema et valider
Générer un JSON Schema à partir de données d'exemple puis valider par rapport à lui.
PIPELINE
Formater JSON et générer une interface TypeScript
Formater un document JSON puis inférer une définition d'interface TypeScript en une chaîne.
PIPELINE
Valider, formater, puis convertir JSON en YAML
Convertir une config JSON (possiblement minifiée) en YAML, capturant les erreurs de syntaxe au premier nœud au lieu de produire un YAML subtilement erroné.
PIPELINE
JSON5 en format JSON
Formater JSON5 et convertir en JSON standard.
PIPELINE
JSONC en format JSON
Formater JSONC (JSON avec commentaires) et convertir en JSON standard.
PIPELINE
Décoder et formater une charge utile JWT
Analyser un token JWT, extraire sa charge utile et formater le JSON pour inspection.
PIPELINE
Analyser chaîne de requête et formater JSON
Analyser une chaîne de requête en paires clé-valeur puis formater en JSON.
PIPELINE
Convertir TOML en JSON
Analyser un fichier de configuration TOML en JSON pour les outils et API attendant une entree JSON.
PIPELINE
Convertir TOML en YAML via JSON
Transformer un fichier de configuration TOML en format YAML, utilisant JSON comme representation intermediaire.
PIPELINE
Decoder un parametre URL imbrique (Base64 JSON)
Derouler un parametre URL transportant du JSON Base64 code URL en JSON formate lisible.
PIPELINE
Generer des interfaces TypeScript depuis YAML
Convertir un document YAML en definitions d'interface TypeScript, utilisant JSON comme format intermediaire.
PIPELINE
Valider et formater YAML
Convertir YAML en JSON pour valider sa structure, puis confirmer que le JSON est bien forme.
PIPELINE

Outils associés