--- title: URL.toJSON() slug: Web/API/URL/toJSON tags: - API - Méthode - Reference - URL - toJSON() translation_of: Web/API/URL/toJSON ---
La méthode toJSON() de l'interface {{domxref("URL")}} retourne un {{domxref("USVString")}} contenant une version sérialisé de l'URL, même si dans la pratique, il semble avoir le même effet que {{domxref("URL.toString()")}}.
{{AvailableInWorkers}}
json = url.toJSON();
Aucun.
A {{domxref("USVString")}}.
const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
url.toJSON()
| Spécification | Statut | Commentaire |
|---|---|---|
| {{SpecName('URL', '#dom-url-tojson', 'toJSON()')}} | {{Spec2('URL')}} | Définition initiale. |
{{Compat("api.URL.toJSON")}}