aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/url/tojson/index.md
blob: 0b5438d49727156413a2ab9f8f18a780d86571b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: URL.toJSON()
slug: Web/API/URL/toJSON
tags:
  - API
  - Méthode
  - Reference
  - URL
  - toJSON()
translation_of: Web/API/URL/toJSON
---
{{APIRef("URL API")}}

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}}

## Syntax

    json = url.toJSON();

### Paramètres

Aucun.

### Valeur retournée

A {{domxref("USVString")}}.

## Exemples

    const url = new URL("https://developer.mozilla.org/en-US/docs/Web/API/URL/toString");
    url.toJSON()

## Spécifications

| Spécification                                                        | Statut               | Commentaire          |
| -------------------------------------------------------------------- | -------------------- | -------------------- |
| {{SpecName('URL', '#dom-url-tojson', 'toJSON()')}} | {{Spec2('URL')}} | Définition initiale. |

## Compatibilité des navigateurs

{{Compat("api.URL.toJSON")}}